Using the Python API to subset AIRS

Please enter here to ask a question about any NASA Science related topics!
Post Reply
crentsch
Posts: 2
Joined: Sun Jul 11, 2021 1:47 pm America/New_York

Using the Python API to subset AIRS

by crentsch » Sun Jul 11, 2021 1:53 pm America/New_York

Following the API code example:
https://disc.gsfc.nasa.gov/information/ ... Subsetting

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
faulty_request.JPG (120.58 KiB) Not viewed yet

Tags:

GES DISC - jimacker
User Services
User Services
Posts: 157
Joined: Mon Sep 30, 2019 1:57 pm America/New_York
Answers: 2

Re: Using the Python API to subset AIRS

by GES DISC - jimacker » Mon Jul 12, 2021 5:20 pm America/New_York

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.

crentsch
Posts: 2
Joined: Sun Jul 11, 2021 1:47 pm America/New_York

Re: Using the Python API to subset AIRS

by crentsch » Tue Jul 13, 2021 1:34 pm America/New_York

Thanks. Would it be more efficient to correspond via email?

GES DISC - jimacker
User Services
User Services
Posts: 157
Joined: Mon Sep 30, 2019 1:57 pm America/New_York
Answers: 2

Re: Using the Python API to subset AIRS

by GES DISC - jimacker » Tue Jul 13, 2021 9:54 pm America/New_York

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/AIR ... RVBRAD_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/ ... ][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.

sjainnahta
Posts: 1
Joined: Mon Oct 25, 2021 3:33 am America/New_York

Re: Using the Python API to subset AIRS

by sjainnahta » Mon Oct 25, 2021 3:37 am America/New_York

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 ... n-pune.php

Post Reply