l2mapgen by command line

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
fbecker23
Posts: 19
Joined: Tue Oct 25, 2022 11:16 am America/New_York
Answers: 0

l2mapgen by command line

by fbecker23 » Fri Jan 27, 2023 1:43 pm America/New_York

Hello,

I have been using the gpt command to process MODIS and VIIRS L2 images of chl and sst. I am using SeaDAS 8.3, with OCSSW installed, and Ubuntu 22.1. In the .xml (attached at the end of the post) in summary what I do is:

read(chl image) --> BandMaths(to create chl and flags bands) -->
Collocate(to bring all the bands together) --> Reproject --> Subset --> Write(as netcdf)
read(sst image) --> BandMaths(to create chl and flags bands) -->

In another post, gnwiii recommended me that the correct treatment for L2 images is to use the l2mapgen function so as not to generate errors on the edges of the image. I have been reading about the l2mapgen function (https://seadas.gsfc.nasa.gov/help-8.1.0/processors/ProcessL2mapgen.html#cl), but I have doubts about it.

I need output files in netcdf format (better if netcdf-CF, that's why I'm using gpt with Snap), can I get a netcdf as output file?

if not, is the procedure I'm doing to process the images using the .xml correct? My goal is to get the L2 image with a regular grid (no matter the projection), the bandmath steps like the subset can be skipped. I'm looking for the regular grid so I can work the images comfortably in python.

Do you know any other way to get a regular grid from a L2 image?

thank you very much for your help

------------------------------------------------------

*file.xml*

<graph id="firstGraph">
<version>1.0</version>

<node id="Read_chl">
<operator>Read</operator>
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>${filechl}</file>
</parameters>
</node>

<node id="BandMaths_chl">
<operator>BandMaths</operator>
<sources>
<sourceProduct refid="Read_chl"/>
</sources>
<parameters>
<targetBands>
<targetBand>
<name>cldice_chl</name>
<expression>l2_flags.CLDICE</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>chlfail_chl</name>
<expression>l2_flags.CHLFAIL</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>land_chl</name>
<expression>l2_flags.LAND</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>bowtiedel_chl</name>
<expression>l2_flags.BOWTIEDEL</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>straylight_chl</name>
<expression>l2_flags.STRAYLIGHT</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>orig_chl</name>
<expression>chlor_a</expression>
<description></description>
<type>float32</type>
<validExpression></validExpression>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>chl</name>
<expression>if chlor_a &gt; 8 or chlor_a &lt; 0.06 then NaN else chlor_a</expression>
<description></description>
<type>float32</type>
<validExpression></validExpression>
<noDataValue>NaN</noDataValue>
</targetBand>
</targetBands>
</parameters>
</node>

<node id="Read_sst">
<operator>Read</operator>
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>${filesst}</file>
</parameters>
</node>

<node id="BandMaths_sst">
<operator>BandMaths</operator>
<sources>
<sourceProduct refid="Read_sst"/>
</sources>
<parameters>
<targetBands>
<targetBand>
<name>cldice_sst</name>
<expression>l2_flags.CLDICE</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>bad_sst</name>
<expression>qual_sst</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>land_sst</name>
<expression>l2_flags.LAND</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>bowtiedel_sst</name>
<expression>l2_flags.BOWTIEDEL</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>straylight_sst</name>
<expression>l2_flags.STRAYLIGHT</expression>
<description></description>
<type>int32</type>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>orig_sst</name>
<expression>sst</expression>
<description></description>
<type>float32</type>
<validExpression></validExpression>
<noDataValue>NaN</noDataValue>
</targetBand>
<targetBand>
<name>sst</name>
<expression>if sst &gt; 30 or sst &lt; 0 then NaN else sst</expression>
<description></description>
<type>float32</type>
<validExpression></validExpression>
<noDataValue>NaN</noDataValue>
</targetBand>
</targetBands>
</parameters>
</node>

<node id="CollocateNode">
<operator>Collocate</operator>
<sources>
<sourceProduct refid="BandMaths_chl"/>>
<sourceProduct.1 refid="BandMaths_sst"/>>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<targetProductType>COLLOCATED</targetProductType>
<resamplingType>NEAREST_NEIGHBOUR</resamplingType>
</parameters>
</node>

<node id="Reproject">
<operator>Reproject</operator>
<sources>
<sourceProduct refid="CollocateNode"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<wktFile/>
<crs>PROJCS[&quot;Mercator_1SP / World Geodetic System 1984&quot;,
GEOGCS[&quot;World Geodetic System 1984&quot;,
DATUM[&quot;World Geodetic System 1984&quot;,
SPHEROID[&quot;WGS 84&quot;, 6378137.0, 298.257223563, AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],
PRIMEM[&quot;Greenwich&quot;, 0.0, AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],
UNIT[&quot;degree&quot;, 0.017453292519943295],
AXIS[&quot;Geodetic longitude&quot;, EAST],
AXIS[&quot;Geodetic latitude&quot;, NORTH]],
PROJECTION[&quot;Mercator_1SP&quot;],
PARAMETER[&quot;latitude_of_origin&quot;, 0.0],
PARAMETER[&quot;central_meridian&quot;, 0.0],
PARAMETER[&quot;scale_factor&quot;, 1.0],
PARAMETER[&quot;false_easting&quot;, 0.0],
PARAMETER[&quot;false_northing&quot;, 0.0],
UNIT[&quot;m&quot;, 1.0],
AXIS[&quot;Easting&quot;, EAST],
AXIS[&quot;Northing&quot;, NORTH]]</crs>
<resampling>Nearest</resampling>
<referencePixelX/>
<referencePixelY/>
<easting/>
<northing/>
<orientation/>
<pixelSizeX/>
<pixelSizeY/>
<width/>
<height/>
<tileSizeX/>
<tileSizeY/>
<orthorectify>false</orthorectify>
<elevationModelName/>
<noDataValue>NaN</noDataValue>
<includeTiePointGrids>true</includeTiePointGrids>
<addDeltaBands>false</addDeltaBands>
</parameters>
</node>

<node id="Subset">
<operator>Subset</operator>
<sources>
<sourceProduct refid="Reproject"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<region>0,0,0,0</region>
<referenceBand/>
<geoRegion>POLYGON ((${east} ${north}, ${west} ${north}, ${west} ${south}, ${east} ${south}, ${east} ${north}))</geoRegion>
<subSamplingX>1</subSamplingX>
<subSamplingY>1</subSamplingY>
<fullSwath>false</fullSwath>
<tiePointGridNames/>
<copyMetadata>true</copyMetadata>
</parameters>
</node>

<node id="Write">
<operator>Write</operator>
<sources>
<source>Subset</source>
</sources>
<parameters>
<file>${ofile}</file>
<formatName>NetCDF4-CF</formatName>
</parameters>
</node>

</graph>

------------------------------------------------------

*file.par*

east=-51
west=-63
north=-35
south=-42

referenceComponentPattern=${ORIGINAL_NAME}_chl
dependentComponentPattern=${ORIGINAL_NAME}_sst

Tags:

OB SeaDAS - xuanyang02
Subject Matter Expert
Subject Matter Expert
Posts: 644
Joined: Tue Feb 09, 2021 5:42 pm America/New_York
Answers: 1
Been thanked: 1 time

Re: l2mapgen by command line

by OB SeaDAS - xuanyang02 » Wed Feb 01, 2023 12:17 pm America/New_York

It's hard to tell if a .xml file is doing what it is supposed to do by just looking at it.

If you share the gpt command line with the ifile name, I can test it for you. As we discussed in the post viewtopic.php?t=3823#p13616, SeaDAS can not write to netCDF4-CF at the moment, so the following block would not work--
<node id="Write">
<operator>Write</operator>
<sources>
<source>Subset</source>
</sources>
<parameters>
<file>${ofile}</file>
<formatName>NetCDF4-CF</formatName>
</parameters>
</node>


If you have questions using SNAP, you should ask them on the SNAP forum -- https://forum.step.esa.int/c/snap/8

For your questions regarding mapgen, see viewtopic.php?p=13790#p13790
Last edited by OB SeaDAS - xuanyang02 on Wed Feb 01, 2023 5:25 pm America/New_York, edited 1 time in total.

fbecker23
Posts: 19
Joined: Tue Oct 25, 2022 11:16 am America/New_York
Answers: 0

Re: l2mapgen by command line

by fbecker23 » Wed Feb 01, 2023 1:54 pm America/New_York

Thanks xuanyang02 for your reply and sorry for the similar post, I thought the other post had not been sent.

I have fixed the command and it works.

Thanks for your help!

Post Reply