Skip to content

module TopoPyScale.topoclass

Toposcale class definition

S. Filhol, September 2021

project/ config.ini -> input/ -> dem/ -> climate/ -> output/


class Topoclass

A python class to bring the typical use-case of toposcale in a user friendly object

method __init__

__init__(config_file)

method compute_dem_param

compute_dem_param()

method compute_horizon

compute_horizon()

Function to compute horizon angle and sample values for list of points


method compute_solar_geometry

compute_solar_geometry()

method downscale_climate

downscale_climate()

method extract_grid_param

extract_grid_param()

method extract_pts_param

extract_pts_param(method='nearest', **kwargs)

Function to use a list point as input rather than cluster centroids from DEM segmentation (topo_sub.py/self.clustering_dem()).

Args: df (dataFrame): - method (str): method of sampling - **kwargs: pd.read_csv() parameters

Returns:


method extract_topo_cluster_param

extract_topo_cluster_param()

Function to segment a DEM in clusters and retain only the centroids of each cluster.

:return:

TODO:

  • try to migrate most code of this function to topo_sub.py as a function itself segment_topo()

method extract_topo_param

extract_topo_param()

Function to select which


method get_WMO_observations

get_WMO_observations()

Function to download and parse in-situ data from WMO database


method get_era5

get_era5()

Funtion to call fetching of ERA5 data

TODO:

  • merge monthly data into one file (cdo?)- this creates massive slow down!

method get_era5_snowmapper

get_era5_snowmapper(surf_plev, lastday)

Funtion to call fetching of ERA5 data

TODO:

  • merge monthly data into one file (cdo?)- this creates massive slow down!

method get_ifs_forecast

get_ifs_forecast()

method get_lastday

get_lastday()

method load_project

load_project()

Function to load pre-existing TopoPyScale project saved in files


method process_SURF_file

process_SURF_file(wdir)

method remap_netcdf

remap_netcdf(filepath)

method search_optimum_number_of_clusters

search_optimum_number_of_clusters(
    cluster_range=array([100, 300, 500, 700, 900]),
    scaler_type=StandardScaler(),
    plot=True
)

Function to test what would be an appropriate number of clusters

Args:

  • cluster_range (int array): numpy array or list of number of clusters to compute scores.

Returns:


method to_crocus

to_crocus(fname_format='CROCUS_pt_*.nc', scale_precip=1)

function to export toposcale output to crocus format .nc. This functions saves one file per point_name

Args:

  • fout_format (str): filename format. point_name is inserted where * is
  • scale_precip (float): scaling factor to apply on precipitation. Default is 1

method to_cryogrid

to_cryogrid(fname_format='Cryogrid_pt_*.nc', precip_partition='continuous')

wrapper function to export toposcale output to cryosgrid format from TopoClass

Args:

  • fname_format (str): filename format. point_name is inserted where * is

method to_fsm

to_fsm(fname_format='FSM_pt_*.txt')

function to export toposcale output to FSM format


method to_geotop

to_geotop(fname_format='meteo_*.txt')

function to export toposcale output to FSM format


method to_musa

to_musa(fname_met='musa_met.nc', fname_labels='musa_labels.nc')

function to export TopoPyScale output in a format compatible with MuSa MuSa: https://github.com/ealonsogzl/MuSA

Args:

  • fname: filename of the netcdf

method to_netcdf

to_netcdf(file_out='output.nc', variables=None)

function to export toposcale output to one single generic netcdf format, compressed

Args:

  • file_out (str): name of export file
  • variables (list str): list of variable to export. Default exports all variables

method to_snowmodel

to_snowmodel(fname_format='Snowmodel_stn_*.csv')

function to export toposcale output to snowmodel format .ascii, for single station standard

fout_format: str, filename format. point_name is inserted where * is


method to_snowpack

to_snowpack(fname_format='smet_pt_*.smet')

function to export toposcale output to FSM format


method to_surfex

to_surfex(
    fname_format='FORCING*.nc',
    scale_precip=1,
    year_start=None,
    year_end=None
)

function to export toposcale output to surfex format .nc. This functions saves one file per point_name

Args:

  • fout_format (str): filename format. point_name is inserted where * is
  • scale_precip (float): scaling factor to apply on precipitation. Default is 1

class Plotting

Sub-Class with plotting functions for topoclass object


method horizon

horizon()

method map_center_clusters

map_center_clusters(
    background_var='elevation',
    cmap=<matplotlib.colors.ListedColormap object at 0x72cb4b5c7dc0>,
    hillshade=True,
    **kwargs
)

method map_clusters

map_clusters(**kwargs)

method map_terrain

map_terrain(var='elevation', hillshade=True, **kwargs)

method map_variable

map_variable(
    var='t',
    time_step=1,
    time=None,
    cmap=<matplotlib.colors.LinearSegmentedColormap object at 0x72cb4b3f1270>,
    hillshade=True,
    **kwargs
)

method solar_geom

solar_geom()

method timeseries

timeseries()

This file was automatically generated via lazydocs.