diff --git a/CFM_main/firn_density_nospin.py b/CFM_main/firn_density_nospin.py index ee99665..804a554 100755 --- a/CFM_main/firn_density_nospin.py +++ b/CFM_main/firn_density_nospin.py @@ -104,9 +104,9 @@ def __init__(self, configName, climateTS = None, NewSpin = False): spinner = os.path.exists(os.path.join(self.c['resultsFolder'], self.c['spinFileName'])) - if ((self.c['isoDiff']) and (climateTS != None)): - print('currently isotope diffusion only available using csv inputs') - self.c['isoDiff']=False + # if ((self.c['isoDiff']) and (climateTS != None)): + # print('currently isotope diffusion only available using csv inputs') + # self.c['isoDiff']=False if ((not spinner) or NewSpin): if self.c['timesetup']=='exact': @@ -183,7 +183,7 @@ def __init__(self, configName, climateTS = None, NewSpin = False): except: self.c['manualT'] = False - if self.c['manualT']: + if self.c['manualT']: # Use temperature measurements from a thermistor string bigTmat = np.loadtxt(os.path.join(self.c['InputFileFolder'],self.c['ManualTFilename']),delimiter = ',') self.manualT_time = bigTmat[0,1:] self.manualT_dep = bigTmat[1:,0] @@ -704,8 +704,11 @@ def __init__(self, configName, climateTS = None, NewSpin = False): for isotope in self.c['iso']: if ((isotope=='d18') or (isotope=='18')): + isotope='d18O' print('rename isotope in .json and forcing file to be d180') - self.Isotopes[isotope] = isotopeDiffusion(self.spin,self.c,isotope,self.stp,self.z,updatedStartDate,self.modeltime) + if isotope=='D': + isotope='dD' + self.Isotopes[isotope] = isotopeDiffusion(self.spin,self.c,isotope,climateTS,self.stp,self.z,updatedStartDate,self.modeltime) ####################### ##################### diff --git a/CFM_main/firn_density_spin.py b/CFM_main/firn_density_spin.py index 1825d52..4baf267 100755 --- a/CFM_main/firn_density_spin.py +++ b/CFM_main/firn_density_spin.py @@ -332,7 +332,12 @@ def __init__(self, config, climateTS = None): self.iso_sig2_out = {} for isotope in self.c['iso']: - self.Isotopes[isotope] = isotopeDiffusion(self.spin,self.c,isotope,self.stp,self.z) + if ((isotope=='d18') or (isotope=='18')): + isotope='d18O' + print('rename isotope in .json and forcing file to be d180') + if isotope=='D': + isotope='dD' + self.Isotopes[isotope] = isotopeDiffusion(self.spin,self.c,isotope,climateTS,self.stp,self.z) ### Surface Density self.rhos0 = self.c['rhos0'] * np.ones(self.stp) # could configure this so that user specifies vector of some noise diff --git a/CFM_main/isotopeDiffusion.py b/CFM_main/isotopeDiffusion.py index 88ef728..7ac7b3b 100644 --- a/CFM_main/isotopeDiffusion.py +++ b/CFM_main/isotopeDiffusion.py @@ -22,7 +22,7 @@ class isotopeDiffusion: Note that presently isotope diffusion only works with .csv inputs. ''' - def __init__(self,spin,config,isotope,stp,z,updatedStartDate,modeltime=None): + def __init__(self,spin,config,isotope,climateTS,stp,z,updatedStartDate=None,modeltime=None): ''' Initialize Isotope diffusion class. @@ -35,13 +35,29 @@ def __init__(self,spin,config,isotope,stp,z,updatedStartDate,modeltime=None): self.c = config self.isotope = isotope + try: - fn = os.path.splitext(self.c['InputFileNameIso']) - isofile = fn[0] + '_{}'.format(self.isotope) + fn[1] - print(isofile) - if isotope=='NoDiffusion': - isofile = fn[0] + '_dD' + fn[1] - input_iso, input_year_iso, input_iso_full, input_year_iso_full = read_input(os.path.join(self.c['InputFileFolder'],isofile),updatedStartDate) + if climateTS != None: + if updatedStartDate is not None: + self.start_ind = np.where(climateTS['time']>=updatedStartDate)[0][0] + else: + self.start_ind = 0 + if isotope=='NoDiffusion': + isokey = 'dD' + else: + isokey = isotope + input_iso = climateTS[isokey][self.start_ind:] + input_year_iso = climateTS['time'][self.start_ind:] + input_iso_full = climateTS[isokey] + input_year_iso_full = climateTS['time'] + + else: + fn = os.path.splitext(self.c['InputFileNameIso']) + isofile = fn[0] + '_{}'.format(self.isotope) + fn[1] + print(isofile) + if isotope=='NoDiffusion': + isofile = fn[0] + '_dD' + fn[1] + input_iso, input_year_iso, input_iso_full, input_year_iso_full = read_input(os.path.join(self.c['InputFileFolder'],isofile),updatedStartDate) if spin: if self.c['spinup_climate_type']=='initial': diff --git a/changelog.md b/changelog.md index 9a94138..b203142 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,7 @@ # CFM Change Log All notable changes to the Community Firn Model should be documented in this file. Contributors to the CFM who are unfamiliar with changelogs should review the notes at the end of this document. -TL;DR: Write down the changes that you made to the the model in this document and update the version number here and in main.py, then update master on github. +TL;DR: Write down the changes that you made to the the model in this document and update the version number here and in main.py, then update main branch on github. To run the update: git commit -a -m "updating to vX.Y.Z. Details in changelog." @@ -12,7 +12,7 @@ git push origin vX.Y.Z Then, on github do a release, which will trigger an updated DOI. ## Current Version -2.0.0 +2.1.0 ## Full Documentation @@ -33,6 +33,13 @@ https://communityfirnmodel.readthedocs.io/en/latest/ - Goujon physics work, but could possibly be implemented more elegantly (it would be nice to avoid globals) - Not exactly in progress, but at some point adding a log file that gets saved in the results folder would be a good idea. +## [2.1.0] 2023-05-31 +### Notes +- This version fixes an issue with how DIP was saved and updates the isotope diffusion module to allow inputs from a dictionary (parallel structure to loading temperature, accumulation rate, etc.) + +### Changed +- *firn_density_nospin.py, isotopeDiffusion.py, firn_density_spin.py* These files have been updated to import the isotope forcing data in the climate import dictionary (climateTS). + ## [2.0.0] 2023-02-28 ### Notes - This is the first major version release (i.e., to 2.x.x) due to several large changes. The first is the addition of a surface energy balance module, SEB.py. The second is a major overhaul in the enthalpy solver.