PALM-meteo: palmmeteo.utils Namespace Reference

PALM-meteo

Loading...
Searching...
No Matches
Classes | Functions | Variables
palmmeteo.utils Namespace Reference

## Classes
class | DTIndexer
class | NotWholeTimestep
class | SliceBoolExtender
class | SliceExtender
class | Workflow

## Functions
| parse_pos (pos, ngrid, resol)
| distribute (what, into, reverse=False)
| distribute_chunks (sizes, nthreads, prefix=(), reverse=False)
| find_free_fname (fpath, overwrite=False)
| tstep (td, step)
| ensure_dimension (f, dimname, dimsize)
| getvar (f, varname, *args, **kwargs)
| assert_dir (filepath)

## Variables
| ax_ = np.newaxis
int | rad = np.pi / 180.
| td0 = datetime.timedelta(0)
| utc = datetime.timezone.utc
| midnight = datetime.time(0)
dt | utcdefault = lambda dt.replace(tzinfo=utc) if dt.tzinfo is None else dt
datetime | midnight_of = lambda dt.datetime.combine(dt.date(), midnight, dt.tzinfo)
int | eps_grid = 1e-3
| fext_re = re.compile(r'\.(\d{3})$')
| pos_re = re.compile(, re.X)
| where_range = lambda mask: (np.argmax(mask), len(mask)-np.argmax(mask[::-1]))
min | nearest_gridpt = lambda v, ngrid(ngrid-1, max(0, round(v)))

## Detailed Description

    A collection of simple, technical utilities.

    These utilities need to be stateless, i.e. they must not depend on config or
    runtime.

## Function Documentation

## ◆ assert_dir()

palmmeteo.utils.assert_dir | ( |  | filepath | ) |

    Creates a directory for an output file if it doesn't exist already.

## ◆ distribute()

palmmeteo.utils.distribute | ( |  | what,
|  |  | into,
|  |  | reverse = `False`
| ) |  |

    Distributes integer into integers as evenly as possible

## ◆ distribute_chunks()

palmmeteo.utils.distribute_chunks | ( |  | sizes,
|  |  | nthreads,
|  |  | prefix = `()`,
|  |  | reverse = `False`
| ) |  |

    Distributes an n-dim array among threads as evenly as possible

## ◆ ensure_dimension()

palmmeteo.utils.ensure_dimension | ( |  | f,
|  |  | dimname,
|  |  | dimsize
| ) |  |

    Creates a dimension in a netCDF file or verifies its size if it already
    exists.

## ◆ find_free_fname()

palmmeteo.utils.find_free_fname | ( |  | fpath,
|  |  | overwrite = `False`
| ) |  |

## ◆ getvar()

palmmeteo.utils.getvar | ( |  | f,
|  |  | varname,
|  | * | args,
|  | ** | kwargs
| ) |  |

    Creates a variable in a netCDF file or returns it if it already exists.
    Does NOT verify its parameters.

## ◆ parse_pos()

palmmeteo.utils.parse_pos | ( |  | pos,
|  |  | ngrid,
|  |  | resol
| ) |  |

    Parse position specified as one of the options (see pos_re). May raise ValueError.

## ◆ tstep()

palmmeteo.utils.tstep | ( |  | td,
|  |  | step
| ) |  |

    Fully divide datetime td by timedelta step.

## Variable Documentation

## ◆ ax_

palmmeteo.utils.ax_ = np.newaxis

## ◆ eps_grid

int palmmeteo.utils.eps_grid = 1e-3

## ◆ fext_re

palmmeteo.utils.fext_re = re.compile(r'\.(\d{3})$')

## ◆ midnight

palmmeteo.utils.midnight = datetime.time(0)

## ◆ midnight_of

datetime palmmeteo.utils.midnight_of = lambda dt.datetime.combine(dt.date(), midnight, dt.tzinfo)

## ◆ nearest_gridpt

min palmmeteo.utils.nearest_gridpt = lambda v, ngrid(ngrid-1, max(0, round(v)))

## ◆ pos_re

palmmeteo.utils.pos_re = re.compile(, re.X)

## ◆ rad

int palmmeteo.utils.rad = np.pi / 180.

## ◆ td0

palmmeteo.utils.td0 = datetime.timedelta(0)

## ◆ utc

palmmeteo.utils.utc = datetime.timezone.utc

## ◆ utcdefault

dt palmmeteo.utils.utcdefault = lambda dt.replace(tzinfo=utc) if dt.tzinfo is None else dt

## ◆ where_range

palmmeteo.utils.where_range = lambda mask: (np.argmax(mask), len(mask)-np.argmax(mask[::-1]))