Ocean Color Forum - Not logged in
Forum Ocean Color Home Help Search Login
Previous Next Up Topic SeaDAS / Non-SeaDAS Packages (e.g. MATLAB, ENVI, GIS, etc) / Matlab for Binned MODIS and SeaWiFS data (locked) (4411 hits)
By jprice Date 2012-05-14 18:23
I am trying to use Matlab to extract the daily chlorophyll a data (MODIS and SeaWiFS) for several lat long coordinates. I am having problems working with the binned data in Matlab and would love some advice.  I am having problems actually getting the data in a usable format. The data is in a Vdata format and I have never worked with that format. I am use to working with a grid where each cell contains a value for a particular location. How do I get the daily chlo a data from the binned data? I have read the information on the ocean level-3 binned data products but I am still confused.

Does anybody know how to extract daily chlorophyll a data for specific coordinates using the binned data?

Below you will find the beginning part of my script that I have been trying to use:

%Script to obtain daily CHL.
%Resulting matrix is comma delimeted in format (Site,Day)
clc;clear;
cd(uigetdir)        %allows you to go get the folder you want to use
%Save main dir location
MainDir = cd;
%Find the file names for all years
Years = ls;
%Remove . and .. this makes it so it will only use the actual files
Years = Years(3:end,:-);
%Loop through all years

for k=1:size(Years,1)
    % Go to k'th year folder
    cd([MainDir,'\',Years(k,:-)]);
    %count the number of files and remove . and ..
    Days = size(ls('*.L3b_DAY_CHL.main'),1);
    % Get all the day names and remove . and ..
    DayNames = ls;
    DayNames = DayNames(3:end,:-);
    for i=1:Days    
        fname =DayNames(i,:-);
        fname1= 'Level-3 Binned Data/chlor_a';
        fname2= 'Fields';
        fname3= 'chlor_a_sum';
         
      CHL=hdfread(fname, fname1, fname2, fname3,'FirstRecord',1 ,'NumRecords',1365113)

Thanks so much!
By @sean Date 2012-05-15 13:18
While not specific to Matlab, there is a lot of useful information on this topic in this thread:
http://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?pid=18311;hl=l3bin%20read#pid18311

Sean
By jprice Date 2012-05-15 14:32
Thanks for your help :-)

I am a little confused with the l3bindump script. Where do I specify the locations I want to use? Could you show me an example? Thanks again!

Jessica
By @sean Date 2012-05-15 14:50
bash-3.2$ l3bindump
Usage:
l3bindump main_file_path parameter bin_number
or
l3bindump main_file_path parameter lat lon radius
or
l3bindump main_file_path parameter north south west east
By norman Date 2012-05-15 15:29
You can also find a bit more detail here.
(I originally named the code swreadl3b.)

Norman
By jprice Date 2012-05-15 15:47
If I want to look at daily data for a 10 year time period will this work?
By norman Date 2012-05-15 16:37
Hi Jessica,

You could craft a script to do what you want.
The following Perl example calls l3bindump
for each Aqua-MODIS daily level-3 chlorophyll
file of the year, 2003, and extracts chlorophyll
data within a 4 kilometer radius of 32 North by
78 West.

perl -e '$gf="http://oceandata.sci.gsfc.nasa.gov/cgi/getfile";' \
     -e 'for($ddd="001";$ddd lt "366";$ddd++){' \
     -e '$f="A2003$ddd.L3b_DAY_CHL.main";' \
     -e 'system("wget -q $gf/$f.bz2")==0 or warn "wget failed" and next;' \
     -e 'system("bunzip2 $f.bz2")==0 or warn "bunzip2 failed" and next;' \
     -e '@lines=split /^/m,`l3bindump $f chlor_a 32 -78 4`;' \
     -e 'if(@lines>3){print "\n$f\n",@lines}' \
     -e 'unlink $f}'

The first couple of results from the above look like this.

A2003008.L3b_DAY_CHL.main
                                                                                        chlor_a         chlor_a
    bin centerlat  centerlon     north     south       west       east    n   N         sum_obs sum_squared_obs          weight  time_trend_bits                     l2_flag_bits sel
------- --------- ---------- --------- --------- ---------- ---------- ---- --- --------------- --------------- --------------- ---------------- -------------------------------- ---
18171469  31.97917  -78.05158  32.00000  31.95833  -78.07614  -78.02702   14   1  8.86437654e-01  2.10220262e-01  3.74165750e+00 0000000000000000 00000000000000000100100000000100   3
18171470  31.97917  -78.00246  32.00000  31.95833  -78.02702  -77.97790   12   1  8.26355755e-01  1.97483048e-01  3.46410155e+00 0000000000000000 00000000000000000100100000000100   3
18171471  31.97917  -77.95334  32.00000  31.95833  -77.97790  -77.92878   11   1  8.34657609e-01  2.10301399e-01  3.31662488e+00 0000000000000000 00000000000000000100100000000100   3
18178797  32.02083  -78.04505  32.04167  32.00000  -78.06962  -78.02048   14   1  9.03065264e-01  2.18366250e-01  3.74165750e+00 0000000000000000 00000000000000000100100000000100   3
18178798  32.02083  -77.99590  32.04167  32.00000  -78.02048  -77.97133   17   1  1.00246203e+00  2.43921340e-01  4.12310553e+00 0000000000000000 00000000000000000100100000000100   3
18178799  32.02083  -77.94676  32.04167  32.00000  -77.97133  -77.92218   15   1  9.53932345e-01  2.35315472e-01  3.87298346e+00 0000000000000000 00000000000000000000100000000100   3

A2003009.L3b_DAY_CHL.main
                                                                                        chlor_a         chlor_a
    bin centerlat  centerlon     north     south       west       east    n   N         sum_obs sum_squared_obs          weight  time_trend_bits                     l2_flag_bits sel
------- --------- ---------- --------- --------- ---------- ---------- ---- --- --------------- --------------- --------------- ---------------- -------------------------------- ---
18171469  31.97917  -78.05158  32.00000  31.95833  -78.07614  -78.02702    9   1  6.55592382e-01  1.43341169e-01  3.00000000e+00 0000000000000000 00000000000000000000000000000000   3
18171470  31.97917  -78.00246  32.00000  31.95833  -78.02702  -77.97790   10   1  7.06802070e-01  1.58056229e-01  3.16227770e+00 0000000000000000 00000000000000000000000000000000   3
18171471  31.97917  -77.95334  32.00000  31.95833  -77.97790  -77.92878   10   1  6.79481983e-01  1.46095201e-01  3.16227770e+00 0000000000000000 00000000000000000000000000000000   3
18178797  32.02083  -78.04505  32.04167  32.00000  -78.06962  -78.02048   18   1  9.43228960e-01  2.09878698e-01  4.24264050e+00 0000000000000000 00000000000000000000000000000000   3
18178798  32.02083  -77.99590  32.04167  32.00000  -78.02048  -77.97133   13   1  7.81231999e-01  1.69440925e-01  3.60555124e+00 0000000000000000 00000000000000000000000000000000   3
18178799  32.02083  -77.94676  32.04167  32.00000  -77.97133  -77.92218   17   1  9.03229058e-01  1.98027164e-01  4.12310553e+00 0000000000000000 00000000000000000000000000000000   3


Development or modification of my example
is left as an exercise for the reader. :-)

Norman
Previous Next Up Topic SeaDAS / Non-SeaDAS Packages (e.g. MATLAB, ENVI, GIS, etc) / Matlab for Binned MODIS and SeaWiFS data (locked) (4411 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