Skip to content

module TopoPyScale.topo_utils


function ds_to_indexed_dataframe

ds_to_indexed_dataframe(ds)

Function to convert an Xarray dataset with multi-dimensions to indexed dataframe (and not a multilevel indexed dataframe). WARNING: this only works if the variable of the dataset have all the same dimensions!

By default the ds.to_dataframe() returns a multi-index dataframe. Here the coordinates are transfered as columns in the dataframe

Args:

  • ds (dataset): xarray dataset with all variable of same number of dimensions

Returns: pandas dataframe:


function multicore_pooling

multicore_pooling(fun, fun_param, n_cores)

Function to perform multiprocessing on n_cores

Args:

  • fun (obj): function to distribute
  • fun_param zip(list): zip list of function arguments
  • n_core (int): number of cores

function multithread_pooling

multithread_pooling(fun, fun_param, n_threads)

Function to perform multiprocessing on n_threads

Args:

  • fun (obj): function to distribute
  • fun_param zip(list): zip list of functino arguments
  • n_core (int): number of threads

function get_versionning

get_versionning()

function FsmMetParser

FsmMetParser(file, freq='1h', resample=False)

Parses FSM forcing files from toposcale sims


function FsmSnowParser

FsmSnowParser(file, freq='1H', resample=False)

parses FSM output fuiles


function FsmPlot_ensemble

FsmPlot_ensemble(wdir, simvar, sampleN)

Function to plot ensemble results for a given variable and point.

Args:

  • wdir: full path to sim directory
  • simvar: variable to plot (str)
  • sampleN: sample number to plot

Returns:

  • sampleN: sample number

Example: FsmPlot_ensemble('/home/joel/sim/topoPyscale_davos/', "HS", 0)


function SmetParser

SmetParser(file, doresample=True, freq='1H', NA_val=-999)

val_file = full path to a smet resample = "TRUE" or "FALSE" freq = '1D' '1H' etc


function getCoordinatePixel

getCoordinatePixel(map_path, x_coord, y_coord, epsg_in, epsg_out)

Function to find which sample a point exists in. Can accept any combination of projections of the map and points.

Args:

  • map_path: full path to map
  • x_coord: x coord of point
  • y_coord: y coord of point
  • epsg_in: input proj epsg code (lonlat: 4326)
  • epsg_out: ouput proj epsg code

Returns:

  • sampleN: sample number

Example: # get epsg of map from TopoPyScale import topo_da as da epsg_out, bbxox = da.projFromLandform(map_path)

getCoordinatePixel("/home/joel/sim/topoPyscale_davos/landform.tif", 9.80933, 46.82945, 4326, 32632)


function val_plots

val_plots()

function time_vecs

time_vecs(start_date, end_date)

Function to build timestamp vectors of year starts and year ends for arbitrary time range.

Args:

  • start_date (str): description
  • end_date (str): description

Returns:

  • start_year: vector of start of years (datetime64)
  • end_year: vector of end of year (datetime64)

This file was automatically generated via lazydocs.