Page 1 of 1

subsetting global images

Posted: Fri Mar 09, 2018 10:21 am America/New_York
by bruce
(this is similar to, but different than https://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?tid=8223)
Are there limited file types that gpt.sh subset can read?  I'm attempting to, at this point, create "pretty pictures" from l3m files using

gpt.sh subset.xml -Ssource=A20053532005360.L3m_8D_PIC_pic_4km.nc -t A20053532005360.L3m_8D_PIC_pic_4km_subset.nc -f netCDF-CF

where subset.xml is

<graph id="someGraphId">
  <version>1.0</version>
  <node id="someNodeId">
    <operator>Subset</operator>
    <sources>
      <source>${source}</source>
    </sources>
    <parameters>
      <region>
  <x>0</x>
  <y>0</y>
      </region>
      <geoRegion>POLYGON(( -10.0 4.0, -76.0 4.0, -76.0 130.0, -10.0 130.0, -10.0 4.0 ))</geoRegion>
      <subSamplingX>1</subSamplingX>
      <subSamplingY>1</subSamplingY>
      <fullSwath>false</fullSwath>
      <copyMetadata>true</copyMetadata>
    </parameters>
  </node>
</graph>

Then I get the dreaded null pointer exception that says...

java.lang.NullPointerException
  at gov.nasa.gsfc.seadas.dataio.SeadasFileReader.<init>(SeadasFileReader.java:94)
  at gov.nasa.gsfc.seadas.dataio.SMIFileReader.<init>(SMIFileReader.java:29)
  at gov.nasa.gsfc.seadas.dataio.SeadasProductReader.readProductNodesImpl(SeadasProductReader.java:149)
  at org.esa.beam.framework.dataio.AbstractProductReader.readProductNodes(AbstractProductReader.java:173)
  at org.esa.beam.gpf.operators.standard.ReadOp.initialize(ReadOp.java:77)
  at org.esa.beam.framework.gpf.internal.OperatorContext.initializeOperator(OperatorContext.java:457)
  at org.esa.beam.framework.gpf.internal.OperatorContext.getTargetProduct(OperatorContext.java:236)
  at org.esa.beam.framework.gpf.Operator.getTargetProduct(Operator.java:323)
  at org.esa.beam.framework.gpf.graph.NodeContext.initTargetProduct(NodeContext.java:74)
  at org.esa.beam.framework.gpf.graph.GraphContext.initNodeContext(GraphContext.java:195)
  at org.esa.beam.framework.gpf.graph.GraphContext.initNodeContext(GraphContext.java:178)
  at org.esa.beam.framework.gpf.graph.GraphContext.initNodeContext(GraphContext.java:178)
  at org.esa.beam.framework.gpf.graph.GraphContext.initOutput(GraphContext.java:162)
  at org.esa.beam.framework.gpf.graph.GraphContext.<init>(GraphContext.java:91)
  at org.esa.beam.framework.gpf.graph.GraphContext.<init>(GraphContext.java:64)
  at org.esa.beam.framework.gpf.graph.GraphProcessor.executeGraph(GraphProcessor.java:124)
  at org.esa.beam.framework.gpf.main.DefaultCommandLineContext.executeGraph(DefaultCommandLineContext.java:84)
  at org.esa.beam.framework.gpf.main.CommandLineTool.executeGraph(CommandLineTool.java:508)
  at org.esa.beam.framework.gpf.main.CommandLineTool.runGraph(CommandLineTool.java:356)
  at org.esa.beam.framework.gpf.main.CommandLineTool.runGraphOrOperator(CommandLineTool.java:249)
  at org.esa.beam.framework.gpf.main.CommandLineTool.run(CommandLineTool.java:150)
  at org.esa.beam.framework.gpf.main.CommandLineTool.run(CommandLineTool.java:122)
  at org.esa.beam.framework.gpf.main.GPT.run(GPT.java:54)
  at org.esa.beam.framework.gpf.main.GPT.main(GPT.java:34)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at com.bc.ceres.launcher.Launcher.launch(Launcher.java:154)
  at com.bc.ceres.launcher.Launcher.main(Launcher.java:56)

Error: java.lang.NullPointerException

so I'm guessing it can't read global l3m files.

If it was 1 or 2 files, I'd do it in the GUI but I'm looking at at least 100 if not more files, automation is a must.

subsetting global images

Posted: Fri Mar 09, 2018 10:34 am America/New_York
by bruce
PS.  Latest version Seadas, CentOS 7 updated last week,

bcb@modis ~]$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

subsetting global images

Posted: Fri Mar 09, 2018 10:44 am America/New_York
by OB.DAAC-EDL - SeanBailey
Bruce,
Danny might respond with a GPT solution ...or not :neutral:
BUT, if you're able to use l3mapgen, it can read the L3m file (yeah, seems somehow not right, but trust me it works) and create a pretty picture:

l3mapgen ifile=A20053532005360.L3m_8D_PIC_pic_4km.nc ofile=A20053532005360.L3m_8D_PIC_pic_4km_subset.nc north=-10 south=-76 east=130 west=4

If you want, you can even spit out a PNG image at the same time by adding ofile2=A20053532005360.L3m_8D_PIC_pic_4km_subset.png

Sean

subsetting global images

Posted: Fri Mar 09, 2018 10:56 am America/New_York
by bruce
You're right, it seems wrong, but it works!
Thanks!

subsetting global images

Posted: Fri Mar 09, 2018 12:19 pm America/New_York
by OB SeaDAS - knowles
Bruce,

You can specify a subset region via one of three parameters: region,  geoRegion, or fullSwath.  Instead, you are simultaneously specifying all three parameters.
It is likely dying because it is probably using the region parameter, in which case you are not including width and height, hence the null exception.  But I think what you want is a geoRegion since I see you've created a polygon, so try removing the following lines from your gpt file:

<region>
     <x>0</x>
     <y>0</y>
</region>
<fullSwath>false</fullSwath>

The fullSwath line doesn't actually conflict since it is set to false, but it is not necessary to include this line as the default is false.

Danny

subsetting global images

Posted: Sat Mar 10, 2018 8:00 pm America/New_York
by gnwiii
It is worth noting that many 3rd party tools can make nice maps from the OCSSW level-3 mapped files.   The HDF Group has HEFEOS Zoo which includes (now obsolete) ocean colour examples that still provide a useful starting point.  I learned about this because data users wanted mapped images consistent in style with maps of other data produced with the users' favored 3rd party tools.  Using NetCDF4-CF, the HDFEOS Zoo examples become simpler. I started work on a NetCDF4-CF Zoo of my own when it was announced that NetCDF4-CF would replace HDF4, but at that time the NetCDF4-CF support in many linux distro packages was still incomplete or broken.   NetCDF4-CF support in 3rd party apps running on linux has improved, but users have been moving to other tools  (ArcGIS, R), and Python Cartopy is replacing basemap.