#!/usr/bin/env python # Last modified: Time-stamp: <2008-05-12 14:59:00 haines> """bogue_dspec_plot""" import os, sys import datetime, time, dateutil, dateutil.tz import pycdf import numpy sys.path.append('/home/haines/nccoos/raw2proc') del(sys) import procutil def which_to_plot(odir, ncfn): """which_to_plot finds which timestamp in netCDF data file (ncfn) does not have a corresponding directional spectrum plot png in output dir (odir) """ nc = pycdf.CDF(ncFile1) # nc = pycdf.CDFMF((ncFile1, ncFile2)) ncvars = nc.variables() # print ncvars es = nc.var('time')[:] units = nc.var('time').units dt = [procutil.es2dt(e) for e in es] dts = [d.strftime('%Y_%m_%d_%H%M') for d in dt] # list all pngs import glob gs = os.path.join(odir, '*.png') all_pngs = glob.glob(gs) ap = ''.join(all_pngs) # find index of dts not in all_pngs j_seq = [j for j in range(len(dts)) if ap.find(dts[j]) != -1] # return index values to plot (j) return j_seq prev_month, this_month, next_month = procutil.find_months(procutil.this_month()) # ncFile1='/home/haines/test_data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_2008_03.nc' # ncFile2='/seacoos/data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_2008_03.nc' # ncFile1='/seacoos/data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_'+prev_month.strftime('%Y_%m')+'.nc' ncFile1='/seacoos/data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_'+this_month.strftime('%Y_%m')+'.nc' odir = os.path.join('/seacoos/data/nccoos/level3/bogue/adcpwaves/dspec', this_month.strftime('%Y_%m')) if not os.path.exists(odir): os.mkdir(odir) # j_seq = which_index_to_plot(odir, ncFile1) # print j_seq