Open sandorkertesz opened 1 year ago
Added JSON schema. All gridspecs (input+output) are validated against it usingjsonschema
, which is now a dependency. https://github.com/ecmwf/earthkit-data/blob/feature/gridspec/earthkit/data/data/gridspec_schema.json
The main purpose of gridspec is to describe the grid structure of a field. Requirements:
Examples:
Interpolation
The idea is that in the yet-to-be-developed
earthkit.regrid
module the gridspec would specify both the input and output grids and we would able to perform an interpolation purely on a numpy array. E.g.:From the results we should be able to create a new
Fieldlist
like this:Now here
ds[0].metadata()
represents the the original "2x2" field whilegs_new
is the gridspec of the new "5x5" field. For users ofds_new
all metadata queries should give results consistent with the new grid:The simplest solution to achieve this is to internally update the metadata object with the gridspec and create a new one. This would require the cloning of a new grib handle (since metadata stores a grib handle internally) from the gridspec. So here the task is to turn the gridspec (in the example it is as simple as
{"grid: [5,5]}
) into the relevant set of grib metadata keys and create the new handle with them. This is already performed inMIR
, which creates the new grib handle from the generated metadata keys with the following call:The question is if we want to duplicate the MIR code in Python or want to delegate this task straight to MIR (i.e. to earthkit.regrid). Please note that
codes_grib_util_set_spec
is not available in the ecCodes Python interface.Work so far
The very first implementation in branch
feature/gridspec
works like this:Generating a new GRIB handle from gridspec is implemented for
regular_ll
grids. An experimental "interpolation" notebook example showcasing this can be found here: https://github.com/ecmwf/earthkit-data/blob/feature/gridspec/docs/experimental/interpolate.ipynbExcerpt from the notebook (here
interpolate
is a method written in scipy just to make the testing work):TODO:
type
is the right name for the grid typeiScansNegatively
. At the moment snake_case is used. E.g.iScansNegatively
->i_scans_negatively
.iScansNegatively
we could usei_scan_direction
with values of -1 or 1TESTING: Gridspec generation can easily be tested with a dictionary containing the relevant grib metadata values for a given field:
output: