Using the Python API to subset AIRS
Using the Python API to subset AIRS
Following the API code example:
https://disc.gsfc.nasa.gov/information/howto?title=How%20to%20Use%20the%20Web%20Services%20API%20for%20Subsetting
I've adapted this for AIRS L1B radiances, but I consistently get "API Error: Faulty Request" with no other information. See attached screenshot.
Any idea what is causing the fault?
https://disc.gsfc.nasa.gov/information/howto?title=How%20to%20Use%20the%20Web%20Services%20API%20for%20Subsetting
I've adapted this for AIRS L1B radiances, but I consistently get "API Error: Faulty Request" with no other information. See attached screenshot.
Any idea what is causing the fault?
- Attachments
-
- faulty_request.JPG (120.58 KiB) Not viewed yet
Tags:
-
- User Services
- Posts: 224
- Joined: Mon Sep 30, 2019 1:57 pm America/New_York
- Has thanked: 2 times
- Been thanked: 2 times
Re: Using the Python API to subset AIRS
Hello,
We have provided your code image to our staff member familiar with the API interface. I will post a reply as soon as possible.
We have provided your code image to our staff member familiar with the API interface. I will post a reply as soon as possible.
-
- User Services
- Posts: 224
- Joined: Mon Sep 30, 2019 1:57 pm America/New_York
- Has thanked: 2 times
- Been thanked: 2 times
Re: Using the Python API to subset AIRS
Here's an initial answer to your query. We can continue through email to our Help Desk if more guidance is necessary.
That product, https://disc.gsfc.nasa.gov/datasets/AIRVBRAD_005/summary?keywords=AIRVBRAD_005, is supported by the SSW and OPeNDAP services, but not by the L2 Subsetter. Spatial subsetting is not supported by either of those services, so it is necessary to change the ‘crop’ arg to ‘False’.
Here is a URL to download those two variables (radiances and scanang) for all Channels from that granule as .nc4 with the following URL:
[https:]//airsl1.gesdisc.eosdis.nasa.gov/opendap/Aqua_AIRS_Level1/AIRVBRAD.005/2003/244/AIRS.2003.09.01.001.L1B.VIS_Rad.v5.0.0.0.G07095063405.hdf.nc4?radiances[0:1:134][0:1:89][0:1:3][0:1:8][0:1:7],scanang[0:1:134][0:1:89]
That product is configured in an unusual way in the search interface – it shows four variables (Channel 1-4, see attached image), but Channel is actually a *dimension* in the file. So the user would get all variables but with that dimension flattened to 1.
That product, https://disc.gsfc.nasa.gov/datasets/AIRVBRAD_005/summary?keywords=AIRVBRAD_005, is supported by the SSW and OPeNDAP services, but not by the L2 Subsetter. Spatial subsetting is not supported by either of those services, so it is necessary to change the ‘crop’ arg to ‘False’.
Here is a URL to download those two variables (radiances and scanang) for all Channels from that granule as .nc4 with the following URL:
[https:]//airsl1.gesdisc.eosdis.nasa.gov/opendap/Aqua_AIRS_Level1/AIRVBRAD.005/2003/244/AIRS.2003.09.01.001.L1B.VIS_Rad.v5.0.0.0.G07095063405.hdf.nc4?radiances[0:1:134][0:1:89][0:1:3][0:1:8][0:1:7],scanang[0:1:134][0:1:89]
That product is configured in an unusual way in the search interface – it shows four variables (Channel 1-4, see attached image), but Channel is actually a *dimension* in the file. So the user would get all variables but with that dimension flattened to 1.
-
- Posts: 1
- Joined: Mon Oct 25, 2021 3:33 am America/New_York
Re: Using the Python API to subset AIRS
Hi,
Let me add a few remarks:
getSolution() is more powerful than getSlack(); while both can be called with (numerical) indices, constraint/variable objects, and constraint/variable names, both alone or in lists/arrays, getSolution() allows for more complex parameters such as expressions or lists thereof: one can call getSolution(x[1] + x[2]) or even getSolution([[x[0]**1, x[1]**2], [x[2]**3, x[3]**4]]), while the same can't happen for getSlack();
the above difference stems from more general function xpress.evaluate(), which evaluates any expression (e.g. a constraint's lhs or part of the objective) using a variable assignment that can be different than the current solution and/or a different problem object. getSolution() is little more than a wrapper for xpress.evaluate();
other functions behave like getSlack(): these are getDual() and getRCost();
efficiency won't be much affected by calling getSlack() or getSolution() with a small subset: the Python interface uses the C API functions for retrieving slack and solution, which however return the whole solution vector requested.
The Python interface then takes care of selecting the right subset. As stated in the Modeling chapter of the python interface's reference manual, calling getSolution(x[i]) or getSlack(constrs[i]) several times will result in as many C API calls that return the whole vector. It is advisable instead to call these functions once.
https://www.sevenmentor.com/best-python-classes-in-pune.php
Let me add a few remarks:
getSolution() is more powerful than getSlack(); while both can be called with (numerical) indices, constraint/variable objects, and constraint/variable names, both alone or in lists/arrays, getSolution() allows for more complex parameters such as expressions or lists thereof: one can call getSolution(x[1] + x[2]) or even getSolution([[x[0]**1, x[1]**2], [x[2]**3, x[3]**4]]), while the same can't happen for getSlack();
the above difference stems from more general function xpress.evaluate(), which evaluates any expression (e.g. a constraint's lhs or part of the objective) using a variable assignment that can be different than the current solution and/or a different problem object. getSolution() is little more than a wrapper for xpress.evaluate();
other functions behave like getSlack(): these are getDual() and getRCost();
efficiency won't be much affected by calling getSlack() or getSolution() with a small subset: the Python interface uses the C API functions for retrieving slack and solution, which however return the whole solution vector requested.
The Python interface then takes care of selecting the right subset. As stated in the Modeling chapter of the python interface's reference manual, calling getSolution(x[i]) or getSlack(constrs[i]) several times will result in as many C API calls that return the whole vector. It is advisable instead to call these functions once.
https://www.sevenmentor.com/best-python-classes-in-pune.php