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']) }
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' else: print("Longitude variable not found")
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: pass
nargs=2, 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'],
import numpy as np import gsw from io_utils.EcoFOCI_netCDF_read import EcoFOCI_netCDF #godas is a function of time, depth, lat, lon (12, 40, 418, 360) godas_ptemp = '/Volumes/WDC_internal/Users/bell/Data_Local/Reanalysis_Files/GODAS/pottmp.1980.nc' godas_sal = '/Volumes/WDC_internal/Users/bell/Data_Local/Reanalysis_Files/GODAS/salt.1980.nc' #GODAS PTEMP df = EcoFOCI_netCDF(godas_ptemp) global_atts = df.get_global_atts() vars_dic = df.get_vars() gd_ptmp = df.ncreadfile_dic() df.close() #GODAS SAL df = EcoFOCI_netCDF(godas_sal) global_atts = df.get_global_atts() vars_dic = df.get_vars() gd_sal = df.ncreadfile_dic() df.close() #ABS Sal f(sal, pres, lat, lon) #pressure needs to be determined from depth ABS_SA = np.ones_like(gd_sal['salt']) CONS_T = np.ones_like(gd_sal['salt']) for time_ind, month in enumerate(gd_sal['time']):
help='output non-epic formatted netcdf as csv') parser.add_argument("-is_whoi","--is_whoi", action="store_true", help='flag if is directly from WHOI') parser.add_argument("-plots","--plots", action="store_true", help='generate plots') args = parser.parse_args() ###nc readin/out file1 = '/Volumes/WDC_internal/Users/bell/ecoraid/2016/Additional_FieldData/ArcticHeat/AlamoFloats/netcdf/arctic_heat_alamo_profiles_9058_9f75_d5e5_f5f9.nc' df = EcoFOCI_netCDF(file1) global_atts = df.get_global_atts() vars_dic = df.get_vars() dims = df.get_dims() data0 = df.ncreadfile_dic() df.close() file2 = '/Volumes/WDC_internal/Users/bell/ecoraid/2016/Additional_FieldData/ArcticHeat/AlamoFloats/netcdf/arctic_heat_alamo_profiles_9115_bb97_cc7e_a9c0.nc' df = EcoFOCI_netCDF(file2) global_atts = df.get_global_atts() vars_dic = df.get_vars() dims = df.get_dims() data1 = df.ncreadfile_dic() if args.is_whoi: timestr = 'days since 1950-01-01T00:00:00Z' else: timestr = 'seconds since 1970-01-01' skipped_vars = ['STATION_PARAMETERS','FLOAT_SERIAL_NO',