FAQ — Frequently Asked Questions¶
Errors¶
I have rather esoterical errors when I try to read a FA file…
=> the
epygram.init_env()
may be initialized at the beginning of your script(s), to be sure thearpifs4py
library do not use MPI, or uses OpenMP with an initialized environment.There is a field in my FA file, unknown by
epygram
(or it seems to be recognized as a MiscField); how can I manage to read it ?=> edit
$HOME/.epygram/user_Field_Dict_FA.csv
, and add your field in the manner of the examples given therein. And warn theepygram
team about it, so that it will enter next version defaultField_Dict_FA.csv
.My PC does not have enough memory to deal with these global spectral fields…
>>> Legendre spectral transforms need XX.XX MB >>> memory, while only YY.YY MB is available: >>> SWAPPING prevented !
=> either:
- run your script on beaufix/prolix usiang the alias
s1batch='sbatch -N 1 -p normal64 --mem 60000 -t 00:30:00'
e.g.:s1batch myscript.py options -of -my --script
- use the
fa_sp2gp.py
tool on Bull (using the above alias) to convert your file to all-gridpoint then work in gridpoint space
- run your script on beaufix/prolix usiang the alias
I have a brutal crash while working with some T1800-or-so global files on beaufix/prolix…
=> before running Python, you need to raise the stack size limit:
ulimit -s unlimited
How to hide LFI/FA messages ?
=> either:
export FA4PY_MUTE=1
- edit
$HOME/.epygram/userconfig.py
and setFA_mute_FA4py = True
How can I… ?¶
How can I plot the sum of several fields ?
7 lines !
>>> import epygram >>> epygram.init_env() >>> r = epygram.formats.resource('myfile', 'r') >>> fld1 = r.readfield('FLD1') >>> fld2 = r.readfield('FLD2') >>> fld_s = fld1 + fld2 >>> fld_s.plotfield(...)
How does it work ?¶
How do
epygram
andvortex
interconnect ?=> Well ! Here is an example (having
vortex
installed), that fetches a resource on the archive and returns anepygram
resource:>>> import epygram >>> epygram.init_env() >>> import usevortex >>> r = usevortex.get_resources(getmode='epygram', # for the function to return the resource as an epygram object experiment='864G', # XPID block='forecast', # Olive/Perl 'forecast' block (directory in archive) kind='gridpoint', # post-processed fields nativefmt='grib', # GRIBbed files date='2015041500', # initial date and time cutoff='prod', # production cutoff term=3, # forecast term geometry='frangp0025', # BDAP domain origin='hst', # some obscure historical characteristic... model='arome', # resource from the AROME model (to be distinguished from the SURFEX file for instance) local='fcst_[term].[nativefmt]') # local filename, once fetched >>> r[0].listfields() >>> ...
Other resource descriptors are available, cf.
usevortex.get_resources()
documentation.vortex
also is able to useepygram
in order to handle a file’s content, cf. Vortex doc.
Evolutivity¶
I have built a new format class
FMFILE
(or whatever else) forepygram
, and I want it to be “fully” integrated in the package locally on my platform (so that theepygram.formats.resource()
can return it). How can I do ?- => edit
$HOME/.epygram/userconfig.py
, and: add
>>> usermodules = [{'name':'FMFILE', 'abspath':'/path/to/FMFILE.py'}]
copy the variable
epygram.config.implemented_formats
in it, addingFMFILE
- => edit
I want to add new features or methods to a class,
epygram.fields.H2DField
for instance, and be sure that my modifications will not be overwritten at the next upgrade ofepygram
…=> build your class
myH2DField
in/path/to/myH2DField.py
, making it inherit fromepygram.fields.H2DField
, as follows:#!/usr/bin/env python # -*- coding: utf-8 -*- import copy import footprints footprints.priorities.set_after('default','user') from epygram.fields import H2DField class myH2DField(H2DField): _footprint = dict( priority = dict( level = footprints.priorities.top.level('user') ) )
For this class to be used by
epygram
, you simply have to add it in$HOME/.epygram/userconfig.py
:>>> usermodules = [{'name':'myH2DField', 'abspath':'/path/to/myH2DField.py'}]
Anyway, if your modifications may be useful to others, propose to the
epygram
team its integration in the next version !I want to add a personal colormap to be used by
epygram
.=> write your colormap as RGB as below
r1,g1,b1; r2,g2,b2; ... rn,gn,bn
into file
mycolormap.cmap
.Then in
$HOME/.epygram/userconfig.py
add:>>> usercolormaps = {'mycolormap':'/path/to/mycolormap.cmap'}
and the colormap is now accesible to
epygram
.If you also want to scale it (i.e. associate the changes of color to discrete, specific values:
in
$HOME/.epygram/userconfig.py
add:>>> usercolormaps_scaling = {'mycolormap':[val_min, val1, val2, ..., val_max]}
(to be continued…)