Web Service Overview | Description | Available Datasets | Parameters | Sample Run
PO.DAAC Web Services

Granule Subset *Beta Version*

URL https://podaac.jpl.nasa.gov/ws/subset/granule
Related Resources Granule Subset Status
Method POST

Description

The Granule Subset web service sets up a granule subsetting job using HTTP POST request. Upon a successful request, a token is returned which can be used to check the status of the subsetting job.

To prevent HTTP timeouts and allow the subsetting of multiple granules at once, the Granule Subset web service has been changed to use the asynchronous method using HTTP POST rather than the HTTP GET. This allows subsetter to process multiple granules more efficiently.

Available Datasets

This service is only available for the following datasets

Dataset ID Short Name

Parameters

BOLD = required

Parameter Details
query Subset instruction in json format
{
    "email":(email address),
    "query": [  
        {
            "datasetId":(dataset id),    
            "bbox":(bbox),
            "variables" : [(variable) , (variable) ],
            "granuleIds": [(granule id), (granule id), ...],
            "compact": false
        }
    ]
}


email address: Once the job is completed, result email will be sent to this email address
dataset id: PODAAC Dataset ID
bbox: subsets based on this given bbox
variable: list of variables to include in the subsetting. Use Dataset Variable Service to retrieve available variables for the dataset
granule ids: list of granules to subset. Granule id can be retrieved from Search Granule Service
compact: true to cut the original scanline width. To reserve the original scanline width, set it to false

For Example

query={ 
    "email":"abc@abcd.com",
    "query": [
        {
            "compact":false,   
            "datasetId":"PODAAC-ASOP2-25X01",
            "bbox":"-180,-90,0,90",
            "variables" : ["lat" , "lon","time","wind_speed" ],
            "granuleIds": ["ascat_20140520_005700_metopa_39344_eps_o_250_2300_ovw.l2.nc","ascat_20140411_175700_metopa_38800_eps_o_250_2300_ovw.l2.nc"]
        }
     ]
}

Sample Run

Subsetting or Downloading granules takes a few WebService calls. First, you need to create input file that contains subsetting instruction. Second, submit the job and retrieve a token. Finally, using the token, you can check the status.

Here is a sample python snippet to do the tasks. testSubsetting.py

#!/usr/bin/python

import sys,math
import httplib, urllib
import json, time



def main(argv):
   #load input file that contins subsetting instruction and submit subset request 

   #read input file
   f = open('input.json', 'r+')
   input = json.load(f)
   inputString = json.dumps(input)

   # submit subset request 
   params = urllib.urlencode({'query':inputString})
   headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "*"}
   conn = httplib.HTTPSConnection("podaac.jpl.nasa.gov")
   conn.request("POST", "/ws/subset/granule?request=submit", params, headers)
   response = conn.getresponse()
   
   data = response.read()
   print data
   result = json.loads(data)
   token =  result['token']
   conn.close()


   #check status on the submitted job until ready

   flag = True
   while (flag):
      conn = httplib.HTTPSConnection("podaac.jpl.nasa.gov")
      conn.request("GET", "/ws/subset/status?token="+token, params)
      response = conn.getresponse()
      data = response.read()
      conn.close()
      result = json.loads(data)
      status = result['status']
      print data
      if (status == 'done') or (status == 'error'):
          flag = False

      time.sleep(1)

   print "Good bye!"


if __name__ == "__main__":
   main(sys.argv[1:])

Here is a sample input.json file.

{
	"email": "abc@abc.com",
	"query": [{
		"datasetId": "PODAAC-ASOP2-25X01",
		"granuleIds": ["ascat_20160409_113000_metopa_49153_eps_o_250_2401_ovw.l2.nc"],
		"bbox": "-180,-90,180,90",
		"variables": ["wvc_index", "model_speed", "model_dir", "ice_prob", "ice_age", "wvc_quality_flag", "wind_speed", "wind_dir", "bs_distance", "lat", "lon", "time"],
		"compact": false
	}]
}

These two files can be downloaded here

testSubsetting.py
input.json

This python script has been tested with Python 2.7. input.json has to be in the same directory as testSubsetting.py. To run the sample open input.json and put your email address and run it as follow

python testSubsetting.py