local_path = res[0].rstrip('\n') # print the Landsat local path in the log ciop.log('DEBUG', 'local path:' + local_path) # create the output name using the dc:identifier metadata field identifier = ciop.casmeta("dc:identifier", line)[0].rstrip('\n') output_name = output_path + '/' + identifier + "_ndvi.tif" # calculate the NDVI obj = ndvi.GDALCalcNDVI() obj.calc_ndvi(local_path, output_name) # use ciop.publish to publish the NDVI result # use the URL returned by ciop.publish as the catalogue online resource info pub = ciop.publish(output_name, driver='s3') ciop.log('DEBUG', pub[0]) # create the NDVI result metadata information # using ciop.casmeta function to access the input product metadata metadata = [ "ical:dtstart=" + ciop.casmeta("ical:dtstart", line)[0].rstrip('\n'), "ical:dtend=" + ciop.casmeta("ical:dtend", line)[0].rstrip('\n'), "dc:identifier=" + identifier + "_NDVI", "dct:spatial=" + ciop.casmeta("dct:spatial", line)[0].rstrip('\n'), "dclite4g:onlineResource=" + pub[0].rstrip()] ciop.log('DEBUG', 'Register the result in the sandbox catalogue') # use ciop.register providing the sandbox local catalogue and # a series template ciop.register('http://localhost/catalogue/sandbox/rdf',
local_path = res[0].rstrip('\n') # print the Landsat local path in the log ciop.log('DEBUG', 'local path:' + local_path) # create the output name using the dc:identifier metadata field identifier = ciop.casmeta("dc:identifier", line)[0].rstrip('\n') output_name = output_path + '/' + identifier + "_ndvi.tif" # calculate the NDVI obj = ndvi.GDALCalcNDVI() obj.calc_ndvi(local_path, output_name) # use ciop.publish to publish the NDVI result # use the URL returned by ciop.publish as the catalogue online resource info pub = ciop.publish(output_name, driver='s3') ciop.log('DEBUG', pub[0]) # create the NDVI result metadata information # using ciop.casmeta function to access the input product metadata metadata = [ "ical:dtstart=" + ciop.casmeta("ical:dtstart", line)[0].rstrip('\n'), "ical:dtend=" + ciop.casmeta("ical:dtend", line)[0].rstrip('\n'), "dc:identifier=" + identifier + "_NDVI", "dct:spatial=" + ciop.casmeta("dct:spatial", line)[0].rstrip('\n'), "dclite4g:onlineResource=" + pub[0].rstrip() ] ciop.log('DEBUG', 'Register the result in the sandbox catalogue') # use ciop.register providing the sandbox local catalogue and # a series template
# import modules import os import sys # import the cioppy module sys.path.append('/usr/lib/ciop/python/') import cioppy as ciop myparam1 = ciop.getparam("param1") myparam2 = ciop.getparam("param2") ciop.log("INFO", "I'm running a job with paramaters " + myparam1 + " " + myparam2) # input comes from STDIN (standard input) for line in sys.stdin: ciop.log('INFO', 'input: ' + line) # copy the input to TMPDIR folder (set as an environmental variable) res = ciop.copy(line, os.environ['TMPDIR']) ciop.log('DEBUG', 'local path:' + res[0].rstrip('\n')) # do something with the local path # publish pub = ciop.publish(os.environ['TMPDIR'] + '/myresult') ciop.log('INFO', 'Done my share of the work!')