parser.add_argument( "-fp", '--full_path', action="store_true", help='provides full path to program: used if run as script') args = parser.parse_args() #read in WPAK data file ncfile = args.DataPath df = EcoFOCI_netCDF(ncfile) global_atts = df.get_global_atts() vars_dic = df.get_vars() ncdata = df.ncreadfile_dic() df.close() nctime = get_UDUNITS(EPIC2Datetime(ncdata['time'], ncdata['time2']), 'days since 0001-1-1') + 1.0 # filter data to convert 1e35 -> np.nan for keynames in ncdata.keys(): if keynames not in [ 'time', 'time2', 'lat', 'lon', 'latitude', 'longitude', 'depth', 'dep' ]: ncdata[keynames][np.where(ncdata[keynames][:, 0, 0, 0] >= 1e30), 0, 0, 0] = np.nan p1 = TimeseriesWPAK(stylesheet='seaborn-poster', labelsize=16) try: t1 = p1.add_title(mooringid=global_atts['MOORING'], lat=ncdata['lat'][0], lon=ncdata['lon'][0],
def set_year_odd(x): if x.year % 2 == 0: return x.replace(year=2000) elif x.year % 2 == 1: return x.replace(year=1999) if nctime[0].year % 2 == 0: nctime = [set_year_even(x) for x in nctime] start_year = 'Even' elif nctime[0].year % 2 == 1: nctime = [set_year_odd(x) for x in nctime] start_year = 'Odd' #nctime = get_UDUNITS(nctime,'days since 0001-01-01') + 1. else: nctime = get_UDUNITS( EPIC2Datetime(ncdata['time'], ncdata['time2']), 'days since 0001-01-01') + 1. #find and replace missing values with nans so they don't plot try: ncdata[plot_var][np.where(ncdata[plot_var] > 1e30)] = np.nan try: label_thin = label_thin + [label[ind]] except TypeError: label_thin = label_thin + [''] except KeyError: pass #Plot data #plt.hold(True)
featureType='' if args.operation in ['CF','CF Convert','CF_Convert']: #generates near file if args.is2D: df = EcoFOCI_netCDF( args.sourcefile ) global_atts = df.get_global_atts() vars_dic = df.get_vars() ncdata = df.ncreadfile_dic() #Convert two word EPIC time to python datetime.datetime representation and then format for CF standards dt_from_epic = EPIC2Datetime(ncdata['time'], ncdata['time2']) if args.time_since_str: time_since_str = " ".join(args.time_since_str) CF_time = get_UDUNITS(dt_from_epic,time_since_str) else: time_since_str = 'days since 1900-01-01' CF_time = get_UDUNITS(dt_from_epic,time_since_str) try: History=global_atts['History'] except: History='' ###build/copy attributes and fill if empty try: data_cmnt = global_atts['DATA_CMNT'] except: data_cmnt = ''