RCMpkl_to_spin¶
2/24/2021
This script takes a pandas dataframe containing climate data for a particular site and generates climate histories to feed into CFM as forcing.
The script resamples the data to the specified time step (e.g. if you have hourly data and you want a daily run, it resamples to daily.)
At present, spin up is generated by just repeatsing the reference climate interval over and over again.
YOU MAY HAVE TO EDIT THIS SCRIPT A LOT TO MAKE IT WORK WITH YOUR FILE STRUCTURE AND WHAT CLIMATE FILES YOU HAVE.
And, for now there are little things you need to search out and change manually, like the reference climate interval. Sorry!
@author: maxstev
-
RCMpkl_to_spin.effectiveT(T)¶ The Arrhenius mean temperature.
-
RCMpkl_to_spin.makeSpinFiles(CLIM_name, timeres='1D', Tinterp='mean', spin_date_st=1980.0, spin_date_end=1995.0, melt=False, desired_depth=None, SEB=False, rho_bottom=916)¶ load a pandas dataframe, called df_CLIM, that will be resampled and then used to create a time series of climate variables for spin up. the index of must be datetimeindex for resampling. df_CLIM can have any number of columns: BDOT, TSKIN, SMELT, RAIN, SUBLIM (use capital letters. We use SMELT because melt is a pandas function) Hopefully this makes it easy to adapt for the different climate products.
UNITS FOR MASS FLUXES IN THE DATAFRAMES ARE kg/m^2 PER TIME STEP SIZE IN THE DATA FRAME. e.g. if you have hourly data in the dataframe, the units for accumulation are kg/m^2/hour - the mass of precip that fell during that time interval.
CFM takes units of m ice eq./year, so this script returns units in that format.
Parameters: - timeres (pandas Timedelta (string)) – Resampling frequency, e.g. ‘1D’ is 1 day; ‘1M’ for 1 month.
- melt (boolean) – Whether or not the model run includes melt
- Tinterp ('mean', 'effective', or 'weighted') –
how to resample the temperature; mean is regular mean, ‘effective’ is Arrhenius mean; ‘weighted’ is accumulation-weighted mean spin_date_st: float
decimal date of the start of the reference climate interval (RCI)- spin_date_end: float
- decimal date of the end of the RCI
Returns: - CD (dictionary) – Dictionary full of the inputs (time, SMB, temperature, etc.) that will force the CFM. Possible keys to have in the dictionary are: ‘time’, which is decimal date; ‘TSKIN’ (surface temperature), ‘BDOT’ (accumulation, m i.e.), ‘SMELT’ (snowmelt, m i.e.), and ‘RAIN’.
- StpsPerYr (float) – number of steps per year (mean) for the timeres you selected.
- depth_S1 (float) – depth of the 550 kg m^-3 density horizon (or other density; you can pick) this is used for the regrid module
- depth_S2 (float) – depth of the 750 kg m^-3 density horizon (or other density; you can pick) this is used for the regrid module
- desired_depth (float) – this is the depth you should set to be the bottom of the domain if you want to model to 916 kg m^-3.
-
RCMpkl_to_spin.toYearFraction(date)¶ convert datetime to decimal date