def load(self): self.data = {} for ind, ncfile in enumerate(self.files_path): print("Working on {0}").format(ncfile) df = EcoFOCI_netCDF(ncfile) df.get_global_atts() vars_dic = df.get_vars() if self.plot_var in vars_dic: ncdata = df.ncreadfile_dic() df.close() ncdata[self.plot_var][np.where( ncdata[self.plot_var] > 1e34)] = np.nan else: continue self.ncdata = ncdata #only save last file self.data[self.pointer_dic['nominal_depth'][ind]] = { 'data': ncdata[self.plot_var][:, 0, 0, 0], 'time': EPIC2Datetime(ncdata['time'], ncdata['time2']) }
databounds = {} if args.multi: ### cycle through all files, retrieve data and plot print files_path writer = pd.ExcelWriter('data/' + MooringID + '_' + plot_var + '.xlsx', engine='xlsxwriter', datetime_format='YYYY-MM-DD HH:MM:SS') label_thin = [] for ind, ncfile in enumerate(files_path): print "Working on {activefile}".format(activefile=ncfile) #open/read netcdf files df = EcoFOCI_netCDF(ncfile) global_atts = df.get_global_atts() vars_dic = df.get_vars() ncdata = df.ncreadfile_dic() df.close() nctime = EPIC2Datetime(ncdata['time'], ncdata['time2']) #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:
description='Convert DegreesWest to DegreesEast inplace') parser.add_argument('sourcefile', metavar='sourcefile', type=str, help='complete path to netcdf file') parser.add_argument('-m360', '--m360', action="store_true", help='make range 0-360') args = parser.parse_args() ###nc readin ncfile = args.sourcefile df = EcoFOCI_netCDF(ncfile) global_atts = df.get_global_atts() vars_dic = df.get_vars() data = df.ncreadfile_dic() if 'lon' in df.variables.keys(): if args.m360: df.variables['lon'][:] = -1. * df.variables['lon'][:] + 360 else: df.variables['lon'][:] = -1. * df.variables['lon'][:] vars_dic['lon'].units = 'degree_east' elif 'longitude' in df.variables.keys(): if args.m360: df.variables['longitude'][:] = -1. * df.variables['longitude'][:] + 360 else: df.variables['longitude'][:] = -1. * df.variables['longitude'][:] vars_dic['longitude'].units = 'degree_east'
type=float, help='fixed temperature scale (min max)') parser.add_argument( '-timebounds', '--timebounds', nargs=3, type=str, help='fixed timebounds start: yyyy-mm-dd end: yyyy-mm-dd "month"') args = parser.parse_args() print "Working on file %s " % args.DataPath nc = EcoFOCI_netCDF(args.DataPath) ncdata = nc.ncreadfile_dic() g_atts = nc.get_global_atts() nc.close() cast_time = EPIC2Datetime(ncdata['time'], ncdata['time2']) doy = np.array([x.timetuple().tm_yday for x in cast_time]) p1 = TimeseriesPorpertyPropertyPlot() try: t1 = p1.add_title(mooringid=global_atts['MOORING'], lat=ncdata['lat'][0], lon=ncdata['lon'][0], depth=ncdata['depth'][0], instrument=args.instname) except KeyError: t1 = p1.add_title(mooringid=global_atts['MOORING'], lat=ncdata['latitude'][0],