Code Monkey home page Code Monkey logo

pyg2p's Issues

Missing Docs/ directory is causing setup.py to fail

python3 branch setup.py fails with the error msg:

copying ./configuration/global/intertables.json -> build/bdist.linux-x86_64/egg/pyg2p/configuration/
copying ./configuration/global/parameters.json -> build/bdist.linux-x86_64/egg/pyg2p/configuration/
copying ./configuration/global/test.json -> build/bdist.linux-x86_64/egg/pyg2p/configuration/
error: can't copy './Docs/UserManual.pdf': doesn't exist or not a regular file

add docstrings to source code

Application is fully documented but classes and methods lack of a minimal documentation (docstrings).

To check if Sphinx would be useful

Using lat, lon and dem in netCDF format

Current version accepts only lat, lon and dem in PCRaster format.
Also check that when netcdf output format flag is set, there is no need of a PCRaster clonemap in configuration.

python3 pyg2p COSMO

https://github.com/ec-jrc/pyg2p/tree/20-py3

Tests on branch 20-py3 fails for COSMO files.
Results show correct values (identical to reference data) but with a different mask. Still no clue why it happens.

Actually, new results seem to be more appropriate/correct, as missing values in COSMO domain are correctly reported while in reference output, values outside COSMO domain are not MV (!).

See attached samples:

cosmo_1
cosmo_2

cosmo_results.zip

Improve pyg2p api: bypass I/O when converting grib to pcr/netcdf

Problem

At ECMWF they need to interpolate precipitation and temperature from COSMO-LEPS gris files (one per member). At the moment, they are using the following hack in python:

def call_pyg2p(args):
    print("Calling: pyg2p "+args)
    return_code = subprocess.call("pyg2p "+args, shell=True)
    if return_code:
        raise RuntimeError("pyg2p returned code: "+str(return_code))

# interpolate precipitation from grib file
def read_precipitation(pyg2p_dir, meteo_dir, ens, tstart, tend):
    template_file = pyg2p_dir+'/cos_r06_1km.json'
    grib_file = meteo_dir+"/"+str(ens)+'.grb'
    pyg2p_args = '--fmap 1 -c '+template_file+' -s '+str(tstart)+' -e '+str(tend)+' -m '+str(ens)+' -o '+str(ens)+'/ -l INFO -i '+grib_file
    call_pyg2p(pyg2p_args)

# interpolate precipitation from grib file
def read_temperature(pyg2p_dir, meteo_dir, ens, tstart, tend):
    template_file = pyg2p_dir+'/cos_t24_1km.json'
    grib_file = meteo_dir+"/"+str(ens)+'.grb'
    pyg2p_args = '--ext 1 --fmap 1 -c '+template_file+' -s '+str(tstart)+' -e '+str(tend)+' -m '+str(ens)+' -o '+str(ens)+'/ -l INFO -i '+grib_file
    call_pyg2p(pyg2p_args)

And then read the resulting pcraster files. I would like to bypass the I/O and get directly the list of pcraster steps from pyg2p.

Proposal:

params = {
        "name": "cosmo_r06",  # optional, just for logging
        "Aggregation": {
            "forceZeroArray": true, 
            "step": 6, 
            "type": "accumulation"
        }, 
        "OutMaps": {
            "cloneMap": "/dataset/maps/europe/dem.map",
            "fmap": 1, 
            "namePrefix": "pR06", 
            "unitTime": 24, 
            "ext": 1,
            "out_dir": "./test/",
            "Interpolation": {
                "latMap": "/dataset/maps/europe/lat.map",
                "lonMap": "/dataset/maps/europe/lon.map",
                "mode": "nearest"
            }
        }, 
       "Parameter": {
            "applyConversion": "k2c", 
            "correctionFormula": "p+gem-dem*0.0065", 
            "demMap": "/dataset/maps/europe/dem.map",
            "gem": "(z/9.81)*0.0065", 
            "shortName": "2t"
        }
    }

interpolated_precipitation  = pyg2p.call(grib_file, params)

Result can be (to decide)

  1. a dictionary with key: timestep and value: ndarray
  2. a pandas series with datetime index

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.