TopoPyScale icon indicating copy to clipboard operation
TopoPyScale copied to clipboard

Adding support for timestep resolutino other than 1hr

Open ArcticSnow opened this issue 2 years ago • 3 comments

Currently TopoPyScale supports only timeseries of 1hr. It would be convenient to add support of 3hr or 6 hr input data. This is in part a follow up of issue #41

ArcticSnow avatar Jan 22 '24 09:01 ArcticSnow

@ArcticSnow i will now implement 3H /6H timestep support. I think this only applies to accumulated variables TP,LW and SW. As far as I can see TP is already divided by timestep here:

down_pt['tp'] = down_pt.precip_lapse_rate * surf_interp.tp * 1 / meta.get('tstep') * 10 ** 3  # Convert to mm/hr

https://github.com/ArcticSnow/TopoPyScale/blob/ac8d71adc73b4d14501e2211abbd44a4b78a05d3/TopoPyScale/topo_scale.py#L184

I need to edit all instances of pd.Timedelta in radiation section, such as:

surf_interp['cle'] = (surf_interp.strd / pd.Timedelta('1H').seconds) / (sbc * surf_interp.t2m ** 4) - \

https://github.com/ArcticSnow/TopoPyScale/blob/ac8d71adc73b4d14501e2211abbd44a4b78a05d3/TopoPyScale/topo_scale.py#L251

can you think of anything else?

joelfiddes avatar Jan 09 '25 15:01 joelfiddes

neat!

check also here:

  • def get_solar_geom() in solar_geom.py
  • fetch_era5() can also be altered that it downloads less data too. line 51 of fetch_era5.py
  • And finally it may be good to define this tstep parameter in the config.yml file. So check how you may transfer the info from the yml to the routine via the topoclass.

This is all I can think of it may affect.

ArcticSnow avatar Jan 10 '25 08:01 ArcticSnow

solar_geom.py alreadzy has tstep defined:

def get_solar_geom(df_position, start_date, end_date, tstep, sr_epsg="4326", num_threads=None, fname='ds_solar.nc', project_ouput=Path('./'), method_solar='nrel_numpy'): """ Function to compute solar position for each location given in the dataframe azimuth is define with 0 towards South, negative in W-dir, and posiive towards E-dir

Args:
    df_position (dataframe): point_name as index, latitude, longitude
    start_date (str): start date  "2014-05-10"
    end_date (str: end date   "2015-05-10"
    tstep (str): time step, ex: '6H'
    sr_epsg (str): source EPSG code for the input coordinate
    num_threads (int): number of threads to parallelize computation on. default is number of core -2
    fname (str): name of netcdf file to store solar geometry
    project_ouput (str): path to project root directory

joelfiddes avatar Jan 16 '25 14:01 joelfiddes

nb: all accumulated variable are accumulated over 1H - therefore:

  • TP is now multplied by timestep to get approximation of full precip budget. No need to deaccumulate as we want mm/hr.
  • RAD (all) is divided by 3600 to get flux W/m2

joelfiddes avatar Jun 19 '25 09:06 joelfiddes