figdir = 'time_series/figs/FC' DO_DATA_COMP = 0 data_comp_str = [psubdirs[1],psubdirs[-1]] # data_comp_str = [psubdirs[1],psubdirs[2]] # continue else: # compare the persistence FCs too psubdirs = ['FC0days','FC2days','PFC1days','PFC2days'] figdir = 'time_series/figs/PFC' DO_DATA_COMP = 0 data_comp_str = [psubdirs[1],psubdirs[-1]] # continue for sdir in subdirs: tsU = mr.read_time_series('time_series/Model_Underest_'+sdir+'.txt') tsO = mr.read_time_series('time_series/Model_Overest_'+sdir+'.txt') tsB = 'time_series/Model_Bias_'+sdir+'.txt' # ============================================================ # get last time series (bias) from over & under time series dates = tsU.dates areaU = tsU.data[akey] areaO = tsO.data[akey] areaT = areaU+areaO data = {akey:areaT} for wkey in Bfields: # get weighted avg for 2 mean widths widU = tsU.data[wkey] widO = tsO.data[wkey]
print('\n') # ============================================================= for wdir in wlist: # loop over weeks its += 1 # place to get results outdir = mdir2 + '/' + wdir + '/analysis/MIZmap/time_series/' if not os.path.exists(outdir): continue olist = os.listdir(outdir) for ofil in olist: if (reg in ofil): O_ts = MR.read_time_series(outdir + ofil) continue W_miz = O_ts.data['Mean_intersecting_width'] W_miz[np.isnan(W_miz)] = 0. # should change some nans to 0? tdays = [] for i, date in enumerate(O_ts.dates): dt = date - refdate ti = dt.total_seconds() * tfac tdays.append(ti) Tmin = min(Tmin, ti) Tmax = max(Tmax, ti) # ================================================================= # write to file:
""" srs='+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45'+\ ' +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs' """ # directories compname = os.getenv('HOSTNAME') if 'hexagon' in compname: #hexagon HEX = True mdir = '/work/timill/RealTime_Models/results_hindcasts/TP4a0.12/wavesice_erai2/' gridpath = None # make time series plots figdir = 'out/' tso1 = mr.read_time_series(figdir + '/thickness_error_winter1.txt') tso2 = mr.read_time_series(figdir + '/thickness_error_winter2.txt') vlist = ['Bias_either_ice', 'RMSE_either_ice'] figs = ['thickness_error_winter1.png', 'thickness_error_winter2.png'] legs = ['Bias', 'RMSE'] refdate = dtm.datetime(2015, 1, 1) tfac = 1. / (24 * 3600) # seconds to days xticks = [] xtlabs = [] for i in range(1, 13): xticks.append((dtm.datetime(2015, i, 1) - refdate).total_seconds() * tfac) xtlabs.append(dtm.datetime(2015, i, 1).strftime('%Y%m%d')) xticks.append((dtm.datetime(2015, i, 15) - refdate).total_seconds() * tfac) xtlabs.append(dtm.datetime(2015, i, 15).strftime('%Y%m%d')) for i in range(1, 3):
def convert_datetime(dto, info): if info['time_units'] == 'days': xfac = 24 * 3600. # seconds in 1 day elif info['time_units'] == 'hours': xfac = 3600. # seconds in 1h elif info['time_units'] == 'minutes': xfac = 60. # seconds in 1min else: xfac = 1. # seconds in 1min return (dto - info['refdate']).total_seconds() / xfac ts = mr.read_time_series(TSfil) yscaling = 1.e-6 # m^2 -> km^2 lines = [] po, lin, info = ts.plot('model_area', time_units='days', yscaling=yscaling) lines.append(lin) po, lin, info = ts.plot('chart_area', time_units='days', yscaling=yscaling, pobj=po) lines.append(lin) # po.ax.set_xlabel('Date') po.ax.set_ylabel('MIZ area, km$^2$') po.ax.legend(lines, ['Model', 'Chart'])
import os, sys import mod_reading as mr from datetime import datetime as DTM from datetime import timedelta as TDEL from matplotlib import pyplot as plt rootdir = '/work/timill/DANY_PAUL_tests' # DMI ice charts # - 1st need to merge DMI time-series 2005,2006 manually # - yearly time series are in /work/shared/nersc/msc/DMI_ice_charts/MIZ_FA/MIZ_polys_classified/[YEAR]/time_series TS = {} ts = mr.read_time_series(rootdir + '/time_series_DMI_2005_2006.txt') TS.update({'DMI': ts}) # print(ts.variables) SETOPT = 1 VBLOPT = 1 if len(sys.argv) >= 2: SETOPT = int(sys.argv[1]) if len(sys.argv) >= 3: VBLOPT = int(sys.argv[2]) # model results ddirs = {'M1' :'CONST_REFR_1days_2005_242_730',\ 'M2' :'CONST_REFR_2days_2005_242_730',\ 'M3' :'CONST_REFR_3days_2005_242_730',\ 'M4' :'CONST_REFR_4days_2005_242_730',\ 'M2L':'CONST_REFR_INIT_LARGE_2days_2005_242_730',\ 'M2D':'CONST_REFR_2days_adv_dfloe_2005_242_730/'}