Skip to content

Commit

Permalink
updating to v2.1.0. Details in changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
maximusjstevens committed May 31, 2023
1 parent e5af223 commit 82da264
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
13 changes: 8 additions & 5 deletions CFM_main/firn_density_nospin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
#######################

#####################
Expand Down
7 changes: 6 additions & 1 deletion CFM_main/firn_density_spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 23 additions & 7 deletions CFM_main/isotopeDiffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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':
Expand Down
11 changes: 9 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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."
Expand All @@ -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

Expand All @@ -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.
Expand Down

0 comments on commit 82da264

Please sign in to comment.