Skip to content

Commit

Permalink
updating to v2.2.0. Details in changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
maximusjstevens committed Jun 26, 2023
1 parent 82da264 commit d7dedbb
Show file tree
Hide file tree
Showing 15 changed files with 800 additions and 531 deletions.
Binary file modified CFM_main/CFMoutput_example/csv/CFMresults.hdf5
Binary file not shown.
Binary file modified CFM_main/CFMoutput_example/csv/CFMspin.hdf5
Binary file not shown.
112 changes: 0 additions & 112 deletions CFM_main/CFMoutput_example/csv/example_csv.json

This file was deleted.

102 changes: 1 addition & 101 deletions CFM_main/RCMpkl_to_spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,63 +125,8 @@ def makeSpinFiles(CLIM_name,timeres='1D',Tinterp='mean',spin_date_st = 1980.0, s
else: #CLIM_name is not a pickle, it is the dataframe being passed
df_CLIM = CLIM_name

# <<<<<<< HEAD
if not SEB:
# drn = {'TS':'TSKIN'} #customize this to change your dataframe column names to match the required inputs
# try:
# df_CLIM['RAIN'] = df_CLIM['PRECTOT'] - df_CLIM['PRECSNO']
# df_CLIM['BDOT'] = df_CLIM['PRECSNO'] + df_CLIM['EVAP']
# except:
# pass
# df_CLIM.rename(mapper=drn,axis=1,inplace=True)
# try:
# df_CLIM.drop(['EVAP','PRECTOT','PRECSNO'],axis=1,inplace=True)
# except:
# pass
# l1 = df_CLIM.columns.values.tolist()
# l2 = ['SMELT','BDOT','RAIN','TSKIN','SRHO']
# notin = list(np.setdiff1d(l1,l2))
# df_CLIM.drop(notin,axis=1,inplace=True)
# # df_BDOT = pd.DataFrame(df_CLIM.BDOT)
# df_TS = pd.DataFrame(df_CLIM.TSKIN)

# res_dict_all = {'SMELT':'sum','BDOT':'sum','RAIN':'sum','TSKIN':'mean','SRHO':'mean'} # resample type for all possible variables
# res_dict = {key:res_dict_all[key] for key in df_CLIM.columns} # resample type for just the data types in df_CLIM

# # df_BDOT_re = df_BDOT.resample(timeres).sum()
# if Tinterp == 'mean':
# df_TS_re = df_TS.resample(timeres).mean()
# elif Tinterp == 'effective':
# df_TS_re = df_TS.resample(timeres).apply(effectiveT)
# elif Tinterp == 'weighted':
# df_TS_re = pd.DataFrame(data=(df_BDOT.BDOT*df_TS.TSKIN).resample(timeres).sum()/(df_BDOT.BDOT.resample(timeres).sum()),columns=['TSKIN'])
# # pass

# df_CLIM_re = df_CLIM.resample(timeres).agg(res_dict)
# df_CLIM_re.TSKIN = df_TS_re.TSKIN
# df_CLIM_ids = list(df_CLIM_re.columns)

# df_CLIM_re['decdate'] = [toYearFraction(qq) for qq in df_CLIM_re.index]
# df_CLIM_re = df_CLIM_re.fillna(method='pad')

# # df_TS_re['decdate'] = [toYearFraction(qq) for qq in df_TS_re.index]
# # df_BDOT_re['decdate'] = [toYearFraction(qq) for qq in df_BDOT_re.index]
# # df_TS_re = df_TS_re.fillna(method='pad')

# stepsperyear = 1/(df_CLIM_re.decdate.diff().mean())

# BDOT_mean_IE = (df_CLIM_re['BDOT']*stepsperyear/917).mean()
# T_mean = (df_TS_re['TSKIN']).mean()
# print(BDOT_mean_IE)
# print(T_mean)

# hh = np.arange(0,501)
# age, rho = hla.hl_analytic(350,hh,T_mean,BDOT_mean_IE)
# if not desired_depth:
# desired_depth = hh[np.where(rho>=rho_bottom)[0][0]]
# depth_S1 = hh[np.where(rho>=550)[0][0]]
# depth_S2 = hh[np.where(rho>=750)[0][0]]
# =======
drn = {'TS':'TSKIN','EVAP':'SUBLIM'} #customize this to change your dataframe column names to match the required inputs
try:
df_CLIM['RAIN'] = df_CLIM['PRECTOT'] - df_CLIM['PRECSNO']
Expand Down Expand Up @@ -249,51 +194,6 @@ def makeSpinFiles(CLIM_name,timeres='1D',Tinterp='mean',spin_date_st = 1980.0, s
depth_S1 = desired_depth * 0.5
depth_S2 = desired_depth * 0.75

# #### Make spin up series ###
# RCI_length = spin_date_end-spin_date_st+1
# num_reps = int(np.round(desired_depth/BDOT_mean_IE/RCI_length))
# years = num_reps*RCI_length
# sub = np.arange(-1*years,0,RCI_length)
# startyear = int(df_CLIM_re.index[0].year + sub[0])
# startmonth = df_CLIM_re.index[0].month
# startday = df_CLIM_re.index[0].day
# startstring = '{}/{}/{}'.format(startday,startmonth,startyear)

# msk = df_CLIM_re.decdate.values<spin_date_end+1
# spin_days = df_CLIM_re.decdate.values[msk]

# smb_spin = df_CLIM_re['BDOT'][msk].values
# tskin_spin = df_CLIM_re['TSKIN'][msk].values

# nu = len(spin_days)
# spin_days_all = np.zeros(len(sub)*nu)
# smb_spin_all = np.zeros_like(spin_days_all)
# tskin_spin_all = np.zeros_like(spin_days_all)

# spin_days_all = (sub[:,np.newaxis]+spin_days).flatten()
# spin_dict = {}
# for ID in df_CLIM_ids:
# spin_dict[ID] = np.tile(df_CLIM_re[ID][msk].values, len(sub))
# # print(spin_days_all[0])

# df_CLIM_decdate = df_CLIM_re.set_index('decdate')
# df_spin = pd.DataFrame(spin_dict,index = spin_days_all)
# df_spin.index.name = 'decdate'

# df_FULL = pd.concat([df_spin,df_CLIM_decdate])
# print('df_full:',df_FULL.head())

# CD = {}
# CD['time'] = df_FULL.index
# for ID in df_CLIM_ids:
# if ID == 'TSKIN':
# CD[ID] = df_FULL[ID].values
# >>>>>>> master
# else:
# desired_depth = desired_depth
# depth_S1 = desired_depth * 0.5
# depth_S2 = desired_depth * 0.75

#### Make spin up series ###
RCI_length = spin_date_end-spin_date_st+1
num_reps = int(np.round(desired_depth/BDOT_mean_IE/RCI_length))
Expand Down Expand Up @@ -380,7 +280,7 @@ def makeSpinFiles(CLIM_name,timeres='1D',Tinterp='mean',spin_date_st = 1980.0, s
hh = np.arange(0,501)
age, rho = hla.hl_analytic(350,hh,T_mean,BDOT_mean_IE)
if not desired_depth:
desired_depth = hh[np.where(rho>=916)[0][0]]
desired_depth = hh[np.where(rho>=rho_bottom)[0][0]]
depth_S1 = hh[np.where(rho>=550)[0][0]]
depth_S2 = hh[np.where(rho>=750)[0][0]]
else:
Expand Down
Loading

0 comments on commit d7dedbb

Please sign in to comment.