def exportData(t1, y1, yErr1, t2, y2, yErr2, table1, variable1, table2, variable2, lat1, lat2, lon1, lon2, depth1, depth2): df = pd.DataFrame() df['time_X'] = t1 df[variable1] = y1 df[variable1 + '_std_X'] = yErr1 df['time_Y'] = t2 df[variable2] = y2 df[variable2 + '_std_Y'] = yErr2 df['lat1'] = lat1 df['lat2'] = lat2 df['lon1'] = lon1 df['lon2'] = lon2 if db.hasField(table1, 'depth') or db.hasField(table2, 'depth'): df['depth1'] = depth1 df['depth2'] = depth2 # dirPath = 'data/' # if not os.path.exists(dirPath): # os.makedirs(dirPath) # path = dirPath + 'XY_' + table1 + '_' + variable1 + '_vs_' + table2 + '_' + variable2 + '.csv' # df.to_csv(path, index=False) export.dump(df, table1, variable1, prefix='Mutual', fmt='.csv') export.dump(df, table2, variable2, prefix='Mutual', fmt='.csv') return
def exportData(cruiseTrack, t, y, yErr, table, variable, margin): df = cruiseTrack df['margin'] = margin # dirPath = 'data/' # path = dirPath + 'Front.csv' # if not os.path.exists(dirPath): # os.makedirs(dirPath) # df.to_csv(path, index=False) export.dump(df, table, variable, prefix='Front', fmt='.csv') return
def sectionMap(tables, variables, dt1, dt2, lat1, lat2, lon1, lon2, depth1, depth2, fname, exportDataFlag): data, lats, lons, subs, frameVars, units = [], [], [], [], [], [] xs, ys, zs = [], [], [] for i in tqdm(range(len(tables)), desc='overall'): if not db.hasField(tables[i], 'depth'): continue df = subset.section(tables[i], variables[i], dt1, dt2, lat1, lat2, lon1, lon2, depth1, depth2) if len(df) < 1: com.printTQDM('%d: No matching entry found: Table: %s, Variable: %s ' % (i+1, tables[i], variables[i]), err=True ) continue com.printTQDM('%d: %s retrieved (%s).' % (i+1, variables[i], tables[i]), err=False) if exportDataFlag: export.dump(df, tables[i], variables[i], prefix='Section', fmt='.csv') times = df[df.columns[0]].unique() lats = df.lat.unique() lons = df.lon.unique() depths = df.depth.unique() shape = (len(lats), len(lons), len(depths)) hours = [None] if 'hour' in df.columns: hours = df.hour.unique() unit = com.getUnit(tables[i], variables[i]) for t in times: for h in hours: frame = df[df[df.columns[0]] == t] sub = variables[i] + unit + ', ' + df.columns[0] + ': ' + str(t) if h != None: frame = frame[frame['hour'] == h] sub = sub + ', hour: ' + str(h) + 'hr' try: shot = frame[variables[i]].values.reshape(shape) except Exception as e: continue data.append(shot) xs.append(lons) ys.append(lats) zs.append(depths) frameVars.append(variables[i]) units.append(unit) subs.append(sub) bokehSec(data=data, subject=subs, fname=fname, ys=ys, xs=xs, zs=zs, units=units, variables=frameVars) return
def exportData(t, y, yErr, table, variable, lat1, lat2, lon1, lon2, extV, extVV, extV2, extVV2): df = pd.DataFrame() df['month'] = t df[variable] = y df[variable + '_std'] = yErr df['lat1'] = lat1 df['lat2'] = lat2 df['lon1'] = lon1 df['lon2'] = lon2 df[extV] = extVV df[extV2] = extVV2 # dirPath = 'data/' # if not os.path.exists(dirPath): # os.makedirs(dirPath) # path = dirPath + 'Monthly_' + table + '_' + variable + '.csv' # df.to_csv(path, index=False) export.dump(df, table, variable, prefix='Monthly', fmt='.csv') return
def exportData(z, y, yErr, table, variable, date1, date2, lat1, lat2, lon1, lon2, fname): df = pd.DataFrame() df['depth'] = z df[variable] = y df[variable+'_std'] = yErr if db.isClimatology(table): df['month1'] = clim.timeToMonth(date1) df['month2'] = clim.timeToMonth(date2) else: df['time1'] = date1 df['time2'] = date2 df['lat1'] = lat1 df['lat2'] = lat2 df['lon1'] = lon1 df['lon2'] = lon2 # dirPath = 'data/' # if not os.path.exists(dirPath): # os.makedirs(dirPath) # path = dirPath + fname + '_' + table + '_' + variable + '.csv' # df.to_csv(path, index=False) export.dump(df, table, variable, prefix='DepthProfile', fmt='.csv') return
def regionalMap(tables, variables, dt1, dt2, lat1, lat2, lon1, lon2, depth1, depth2, fname, exportDataFlag): data, lats, lons, subs, frameTables, frameVars = [], [], [], [], [], [] for i in tqdm(range(len(tables)), desc='overall'): df = subset.spaceTime(tables[i], variables[i], dt1, dt2, lat1, lat2, lon1, lon2, depth1, depth2) if len(df) < 1: com.printTQDM( '%d: No matching entry found: Table: %s, Variable: %s ' % (i + 1, tables[i], variables[i]), err=True) continue com.printTQDM('%d: %s retrieved (%s).' % (i + 1, variables[i], tables[i]), err=False) if exportDataFlag: export.dump(df, tables[i], variables[i], prefix='Regional', fmt='.csv') if com.isGrid(tables[i], variables[i]): data, lats, lons, subs, frameTables, frameVars = structuredMap( df, tables[i], variables[i], data, lats, lons, subs, frameTables, frameVars) else: dashboardPanels(df, tables[i], variables[i]) # data, lats, lons, subs, frameTables, frameVars = interpolatedMap(df, tables[i], variables[i], data, lats, lons, subs, frameTables, frameVars) bokehMap(data=data, subject=subs, fname=fname, lat=lats, lon=lons, tables=frameTables, variables=frameVars) return
def exportData(y, table, variable, startDate, endDate, lat1, lat2, lon1, lon2, depth1, depth2): df = pd.DataFrame() df[variable] = y timeField = 'time' if db.isClimatology(table) and db.hasField(table, 'month'): timeField = 'month' df['start_' + timeField] = startDate df['end_' + timeField] = endDate df['lat1'] = lat1 df['lat2'] = lat2 df['lon1'] = lon1 df['lon2'] = lon2 if db.hasField(table, 'depth'): df['depth1'] = depth1 df['depth2'] = depth2 # dirPath = 'data/' # if not os.path.exists(dirPath): # os.makedirs(dirPath) # path = dirPath + 'Hist_' + table + '_' + variable + '.csv' # df.to_csv(path, index=False) export.dump(df, table, variable, prefix='Hist', fmt='.csv') return