Ocean Color Forum - Not logged in
Forum Ocean Color Home Help Search Login
Previous Next Up Topic SeaDAS / SeaDAS 6.x - General Questions / l2_flags Level-2 product to isolate and modify certain Level-2 data pixels? (1130 hits)
By monachus Date 2012-07-17 14:59
Hi Mike, I have tried to modify the code in below link to have an ascii output but I could not succeed. I am extracting 25 closest point from time series data for one station by using l2 modis and seawifs files. I am running a python script to choose these points from the ascii output of the l2 files. My problem is: some pixels which are processed in the L2 files are not real. I mean, in an oligotrophic region points comes up with chlorophyll values like 30-17 mg/m3 which are not OK. So I would like to apply L3 flags before having the ascii output, therefor I tried to use the script which you have suggest below but I could not add ascii_out. Is there a solution for this.

http://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?pid=8516

Thanks

Hasan
By @sean Date 2012-07-17 19:01
Hasan,

You'll need to create a new band with the flagged pixels masked out, then output the data from this new band. 
There are examples of using mband_cmd to do this posted on this forum, one of which is: http://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?pid=10552#pid10552

Sean
By monachus Date 2012-07-18 12:19
Hi Sean,

Well I did, but I got only chlorophyll values in a separate hdf file. I would prefer to add this new band to the original file, which is not visible by seadas in refer to (http://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?tid=4462). The reason to do this, is the missing navigation information. New band which is created by having only pixel and line data. In this case I could not find my nearest point from different L2 scenes which are definitely not same size. Is it possible have lat lon values somehow. Other interesting point is: when I append same data to the file which I created is visible by seadas contrary to appending it to the original file?......

Thanks

Hasan
By monachus Date 2012-07-18 14:14
Hi, I just find a trick to get an ascii out and also display (with GUI) the band from appended file. The trick is to load the final file as HDF. In this case you may have seen this appended band. On the other hand if you want to have an ascii output from this new file you only need to load your file as hdf. My scripts are below. For GUI; first I load a normal hdf file and then without closing the window, just writing the name of the file with full path in this window and press load you may seen all the hdf bands..
[img][/img]
##############Script for appending new band to the original file. You may have different flags.###############################

load, 'S2003289044020.L2_MLAC_OC.x2.hdf', prod_name=['chlor_a','l2_flags'] & $
display, band_no=1, fbuf=1 & $
load_graph, 2, fbuf=1, ftype='BAND', bit=[1,2,4,5,6,9,10], color=[7] & $
mband_cmd, navband=1, cmd_array=['result=b1', 'ix=WHERE(GR1 EQ 7, icnt)', 'if (icnt GT 0) then result(ix)=-999'] & $
out, 'S2003289044020.L2_MLAC_OC.x2.hdf',  /data, band=3, ftype='HDF', /geo, /interlace, append=1

##############Output script. In this case ascii out is used.####################
; PRO matchups

; this is an example that extracts matchups from L2

product='new band'

; pt1 and pt2 must be in *lon/lat* order
; using a very small region will result in a one pixel extraction
pt1=[110.056, 11.85] ; bottom right corner
pt2=[109.965, 11.95] ; top left corner

; vars=[3,4,5,6,2] corresponds to lat, lon, pixel, line, geo
vars=[3,4,5,6,2]
format='(F10.3,F10.3,I,I,F10.4)'

filenames=findfile('S2003289044020.L2_MLAC_OC.x2.hdf')
for i=0,n_elements(filenames)-1 do begin & $
   filename=filenames(i) & $
   print,'filename = ', filename & $
   base=strmid(filename,0,14) & $
   matchup_file=base+'_matchup.txt' & $
   load,filename, ftype='hdf', prod_name=product & $
   out_ascii, matchup_file, band_no=1, region=[pt1,pt2], vars=vars, format=format, titles=0, /ll_flag & $

  clear_up & $
endfor

By @sean Date 2012-07-19 13:10
Hasan,
When using the mband_cmd function, you have the option of choosing to use the navigation from an already loaded band for the newly created band.
Then when you export the file, it will have navigation information associated with it.  See the mband_cmd help for more information.

Sean
By monachus Date 2012-07-23 14:18
Hi Sean,

I did not succeed!!!!. I am not really sure how this is working but as I understood; below code should result a file with navigation info in it, but it is not. Navband option is only allowing mband_cmd command but the result file has no any navi info. Could you please give me more specific idea. I need to extract some points after flag the data from these files therefor lat lon info is crucial for me....

best

Hasan

load, 'test.hdf', prod_name=['chlor_a','l2_flags'] & $
display, band_no=1, fbuf=1 & $
load_graph, 2, fbuf=1, ftype='BAND', bit=[1,4,5,6,9,10,13,15,16,17,20,22,23,26], color=[7] & $
mband_cmd, navband=1, cmd_array=['result=b1', 'ix=WHERE(GR1 EQ 7, icnt)', 'if (icnt GT 0) then result(ix)=-999'] & $
display, band_no=3, fbuf=2 & $
out, 'test2.hdf', ftype='HDF', /geo
By @sean Date 2012-07-23 14:50
Try using the following "out" commands to export  the data with navigation to an HDF file:

out,'test2.hdf',ftype='HDF',/data, band=3,dfmt=4
out,'test2.hdf',ftype='HDF',band=3,/nav,/append


Sean
Previous Next Up Topic SeaDAS / SeaDAS 6.x - General Questions / l2_flags Level-2 product to isolate and modify certain Level-2 data pixels? (1130 hits)



Responsible NASA Official: Gene C. Feldman
Curator: OceanColor Webmaster
Authorized by: Gene C. Feldman
Updated: 27 November 2007
Privacy Policy and Important Notices NASA logo