NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/proc2plot/trunk/proc2plot/scratch/scr_which_to_plot.py

Revision 329 (checked in by haines, 14 years ago)

import first verison proc2plot

Line 
1 #!/usr/bin/env python
2 # Last modified:  Time-stamp: <2008-05-12 14:59:00 haines>
3 """bogue_dspec_plot"""
4
5 import os, sys
6 import datetime, time, dateutil, dateutil.tz
7 import pycdf
8 import numpy
9
10 sys.path.append('/home/haines/nccoos/raw2proc')
11 del(sys)
12
13 import procutil
14
15 def which_to_plot(odir, ncfn):
16     """which_to_plot finds which timestamp in netCDF data file
17     (ncfn) does not have a corresponding directional spectrum plot png
18     in output dir (odir) """
19
20     nc = pycdf.CDF(ncFile1)
21     # nc = pycdf.CDFMF((ncFile1, ncFile2))
22     ncvars = nc.variables()
23     # print ncvars
24     es = nc.var('time')[:]
25     units = nc.var('time').units
26     dt = [procutil.es2dt(e) for e in es]
27     dts = [d.strftime('%Y_%m_%d_%H%M') for d in dt]
28     # list all pngs
29     import glob
30     gs = os.path.join(odir, '*.png')
31     all_pngs = glob.glob(gs)
32     ap = ''.join(all_pngs)
33     # find index of dts not in all_pngs
34     j_seq = [j for j in range(len(dts)) if ap.find(dts[j]) != -1]
35     # return index values to plot (j)
36     return j_seq
37    
38
39 prev_month, this_month, next_month = procutil.find_months(procutil.this_month())
40 # ncFile1='/home/haines/test_data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_2008_03.nc'
41 # ncFile2='/seacoos/data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_2008_03.nc'
42 # ncFile1='/seacoos/data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_'+prev_month.strftime('%Y_%m')+'.nc'
43 ncFile1='/seacoos/data/nccoos/level1/bogue/adcpwaves/bogue_adcpwaves_'+this_month.strftime('%Y_%m')+'.nc'
44 odir = os.path.join('/seacoos/data/nccoos/level3/bogue/adcpwaves/dspec', this_month.strftime('%Y_%m'))
45 if not os.path.exists(odir):
46     os.mkdir(odir)
47
48 # j_seq = which_index_to_plot(odir, ncFile1)
49 # print j_seq
Note: See TracBrowser for help on using the browser.