Not logged inOcean Color Forum

The forum is locked.

The Ocean Color Forum has transitioned over to the Earthdata Forum (https://forum.earthdata.nasa.gov/). The information existing below will be retained for historical reference. Please sign into the Earthdata Forum for active user support.

Up Forum
Search
thank you very much! I have solved this problem. The detail was replied to gnwiii!
thanks, Prof.:
     I have solved this problem. It is an environment variable setting problem in python script. Because the "source $OCSSWROOT/OCSSW_bash.env" is a temporary setting in my Linux OS (i do not know the reason). Therefore, I have to set this environment variable group in the python script. the following code is to solve this problem.
=================================python script=====================================================           
                import subprocess
                commands = 'source $OCSSWROOT/OCSSW_bash.env;l2gen -h'
                process = subprocess.Popen(commands,executable='/bin/bash', stdin=subprocess.PIPE, stdout=subprocess.PIPE,shell=True)
                out, err = process.communicate()
==============================================================================================
    where: commands includes two command lines: 'source $OCSSWROOT/OCSSW_bash.env' and 'l2gen -h'. Note that executable is '/bin/bash'.
Thank you very much!
Thank Seadas developing group and ocean color community!
sorry for my unclear question!
the detail is:
   my os and software environment:  VMware workstation Pro 14, ubuntu16.04 X64, seadas7.5.3, anaconda/python3.7.3, pycharm education 2019
   my scheme is that using “l2gen” to process MODIS L1B data (MOD021KM.**hdf) by python script.
   (1) The following coding can work in bash shell terminal: 
==========================the command lines=========================================
l2gen ifile=/mnt/hgfs/share/test/MOD021KM.A2009033.0810.061.2017295060325.hdf geofile=/mnt/hgfs/share/test/MOD03.A2009033.0810.061.2017294135803.hdf ofile=/mnt/hgfs/share/test/MOD021KM.A2009033.0810.061._seadas.hdf
===============================================================================
     the perfect result file "ofile" is available.

    (2) But similar coding cannot work in python script:
==========================the python script: MODIS-l2gen====================================
import subprocess,os,glob
if __name__=='__main__':
    ifiles=glob.glob('/mnt/hgfs/share/test/MOD021KM*.hdf')
    with open('/mnt/hgfs/share/test/processing_log.txt','w') as f:
        for i,ifile in enumerate(ifiles):
            dir=os.path.dirname(ifile)
            name=os.path.basename(ifile)
            ID=name[9:27]
            #print(dir+'/'+'MOD03.'+ID+'*hdf')
            geofile=glob.glob(dir+'/'+'MOD03.'+ID+'*hdf')[0]

            ofile=dir+'/'+name[0:27]+'_seadas.hdf'
            maskland = 1
            cloudland = 1
            slat=17
            slon=117
            elat=19
            elon=118
            l2prod = 'La_748 La_859 La_869 La_vvv Rrs_vvv angstrom aot_nnn brdf brdf_748 brdf_859 brdf_869\
                     brdf_vvv chlor_a'
            l2gencmd1='l2gen'+' ifile='+ ifile +' geofile='+ geofile +' ofile='+ ofile +' slat='+ \
                     str(slat)+' slon='+str(slon)+' elat='+str(elat)+' elon='+str(elon)+\
                     ' l2prod='+str(l2prod)
            l2gencmd2 = 'l2gen' + ' ifile=' + ifile + ' geofile=' + geofile + ' ofile=' + ofile
            print(l2gencmd2)
            l2cmdtest = 'l2gen -h'
            try:
                #new_env = os.environ.copy()
                #new_env['OCSSWROOT'] = '/usr/local/seadas-7.5.3/ocssw'
                returnCodetest = subprocess.call(l2cmdtest, shell=True)
                returnCode2 = subprocess.call(l2gencmd2, shell=True)
                returnCode1 = subprocess.call(l2gencmd1 ,shell=True)
            except:
                f.write(ifile+'\n')
===========================================================================
the error:
/bin/sh: 1: l2gen: not found

  (3) the question:
     I don't know why the python script did not can work. I have set environment according https://seadas.gsfc.nasa.gov/downloads/
the l2gen can run in terminal. but dont in python. the error is:sh: 1: l2gen: not found.
according to google searching result, the environment variable need to be set again in python script. the method is:
     new_env=os.env.copy()
     new_env['OCSSWROOT'] = '/usr/local/seadas-7.5.3/ocssw'
     returnCode = subprocess.call(l2genshell , env=new_env,shell=True)
there is a problem that environment variables in OCSSW_bash.env can not be add to new_env by using SOURCE command line.
But there is few question/answer to demonstrate how to parse the xxx.env file (OCSSW_bash.env) in python.
How should i add this environment variable in python script? THANKS
harris@ubuntu:~$ l2gen,ifile="/home/quzhou/PycharmProjects/modis/MOD021KM.A2008094.0230.061.2017255063942.hdf",geofile="/home/quzhou/PycharmProjects/modis/MOD03.A2008094.0230.061.2017255024925.hdf",ofile="/home/quzhou/PycharmProjects/modis/Tmodis.HDF"
bash: l2gen,ifile=/home/quzhou/PycharmProjects/modis/MOD021KM.A2008094.0230.061.2017255063942.hdf,geofile=/home/quzhou/PycharmProjects/modis/MOD03.A2008094.0230.061.2017255024925.hdf,ofile=/home/quzhou/PycharmProjects/modis/Tmodis.HDF: No such file or directory

the ifile and geofile exist.

if I execute l2gen in MODIS file folder:
(base) quzhou@ubuntu:~/PycharmProjects/modis$ l2gen,ifile="MOD021KM.A2008094.0230.061.2017255063942.hdf",geofile="MOD03.A2008094.0230.061.2017255024925.hdf",ofile='T2008094023000.L2_LAC_OC'
l2gen,ifile=MOD021KM.A2008094.0230.061.2017255063942.hdf,geofile=MOD03.A2008094.0230.061.2017255024925.hdf,ofile=T2008094023000.L2_LAC_OC: command not found

However, "l2gen -h"  is a valid command
Thank you, Dr. White.
     In most processing, I use the IDL/ENVI and python to achieve my goal. But this, the seadas is necessary. I need to achieve atmospheric correction for MODIS with method embedded in seadas. I tried to code in IDL with the Rayleigh and aerosol look-up table of seadas. however, the accuracy of Rrs is always lower than seadas. Today, I find the GUI is editable as the picture in URI. Interesting!!! If it is a code editor, the parameter setting will be very easy. I wanted to test it,but I don't know the supported program language (python?). Of course, I would find the way you told to achieve my processing goal.
    Thank you, Dr. thanks for your reply and wish you good health!
Hello,
      Batch processing is necessary for the amount of remote sensing imagery. the developers provide batch processing mode in seadas software package. But I find not an example of this mode. In processing, i find the white panel is an editable region. is this an editor for coding? If so,how to use looping in this editor?
The .img file about this white panel region is there:
https://github.com/lwk1542/seaDAS/blob/master/seadasQuestion.png
thanks,!!!
Topic Does the ancillary web be changed? By lwk1542 Date 2019-01-18 03:00
There is a error in installing seadas-V7.5.1:
"
Installing seawifs-luts (9 of 9)
Bad response for https://oceandata.sci.gsfc.nasa.gov/Ancillary/LUTs/seawifs/?format=json: 400  Bad Request
  '''''
return response and ('json' in response.getheader('content-type'))
TypeError: argument of type 'NoneType' is not iterable
"
I check the web (https://oceandata.sci.gsfc.nasa.gov/Ancillary/LUTs/seawifs/), and no any json file was found.

so, the web has been changed?
Topic seadas7.5.1 installing issure fro By lwk1542 Date 2019-01-17 03:39
Zhigang,
    Thanks for your help. I update GIT, but it seems not to work.

lwk@ubuntu:~/seadas-7.5.1$ git ls-remote "https://oceandata.sci.gsfc.nasa.gov/git/obpgpyutils/" HEAD
be40eb6871cf353024c22bdd8e4b014b91bc414a  HEAD

lwk@ubuntu:~/seadas-7.5.1$ ./install_ocssw.py  --aqua
Installing bundles.sha256sum (1 of 10)
--2019-01-16 19:31:59--  https://oceandata.sci.gsfc.nasa.gov/ocssw/bundles.sha256sum
Connecting to 127.0.0.1:46459... connected.
Proxy request sent, awaiting response... 200 OK
Length: 3719 (3.6K) [application/octet-stream]
Saving to: ‘bundles.sha256sum’

bundles.sha256sum   100%[===================>]   3.63K  --.-KB/s    in 0s     

2019-01-16 19:32:00 (855 MB/s) - ‘bundles.sha256sum’ saved [3719/3719]

Installing common (2 of 10)
Installing OCSSW_bash.env (3 of 10)
--2019-01-16 19:32:04--  https://oceandata.sci.gsfc.nasa.gov/ocssw/OCSSW_bash.env.v7.5
Connecting to 127.0.0.1:46459... connected.
Proxy request sent, awaiting response... 200 OK
Length: 3001 (2.9K) [application/octet-stream]
Saving to: ‘OCSSW_bash.env.v7.5’

OCSSW_bash.env.v7.5 100%[===================>]   2.93K  --.-KB/s    in 0s     

2019-01-16 19:32:05 (518 MB/s) - ‘OCSSW_bash.env.v7.5’ saved [3001/3001]

Installing ocrvc (4 of 10)
Installing modis (5 of 10)
Installing modis/aqua (6 of 10)
Installing bin (7 of 10)
Installing opt (8 of 10)
Installing scripts (9 of 10)
Python version acceptable
Installing aqua-luts (10 of 10)
Bad response for https://oceandata.sci.gsfc.nasa.gov/Ancillary/LUTs/modis/?format=json: 400  Bad Request
Traceback (most recent call last):
  File "/home/lwk/ocssw/scripts/update_luts.py", line 66, in <module>
    luts.get_luts()
  File "/home/lwk/ocssw/scripts/modules/LutUtils.py", line 128, in get_luts
    regex='^((?!\d+).)*' + suffix, check_times=True)
  File "/home/lwk/ocssw/scripts/modules/JsonUtils.py", line 269, in download_allfiles
    all_links = self.get_links(url, regex=regex)
  File "/home/lwk/ocssw/scripts/modules/JsonUtils.py", line 237, in get_links
    if is_json(response):
  File "/home/lwk/ocssw/scripts/modules/JsonUtils.py", line 135, in is_json
    return response and ('json' in response.getheader('content-type'))
TypeError: argument of type 'NoneType' is not iterable
Error - Could not install luts for aqua
Topic seadas7.5.1 installing issure fro By lwk1542 Date 2019-01-16 04:02
the error occure in the last step "update_lut". how should i solve this problem?
......
Python version acceptable
Installing aqua-luts (10 of 10)
Bad response for https://oceandata.sci.gsfc.nasa.gov/Ancillary/LUTs/modis/?format=json: 400  Bad Request
Traceback (most recent call last):
  File "/home/lwk/ocssw/scripts/update_luts.py", line 66, in <module>
    luts.get_luts()
  File "/home/lwk/ocssw/scripts/modules/LutUtils.py", line 128, in get_luts
    regex='^((?!\d+).)*' + suffix, check_times=True)
  File "/home/lwk/ocssw/scripts/modules/JsonUtils.py", line 269, in download_allfiles
    all_links = self.get_links(url, regex=regex)
  File "/home/lwk/ocssw/scripts/modules/JsonUtils.py", line 237, in get_links
    if is_json(response):
  File "/home/lwk/ocssw/scripts/modules/JsonUtils.py", line 135, in is_json
    return response and ('json' in response.getheader('content-type'))
TypeError: argument of type 'NoneType' is not iterable
Error - Could not install luts for aqua
Topic seadas v7.5.1 installation issue By lwk1542 Date 2019-01-15 10:11
sorry to disturb you. how do you solve this  problem?
Because of the barrier of the internet in China, the seadas software cannot be used. But there is another method for me.
The C program of SeaDAS (such as aerosol.c) can be taken from the website https://oceancolor.gsfc.nasa.gov/docs/ocssw/dir_5516ca9d074c0c1cd79f549c776fccc5.html.
Can these C programs be cited and rewrote under the authorization of SeaDAS? if so, is there any case or guideline for using python to cite C program.
thanks!
Topic Can the ocssw source code of C be obtained? By lwk1542 Date 2018-12-06 14:01
on the page(https://oceandata.sci.gsfc.nasa.gov/ocssw/), I only found the .bundle file which cannot be unzipped and read.
Is there any source code that can be read line-by-line?
hello,i am a student doing my postgraduate. I need to simulate the radiative transfer, recently. but I dont know how to set relative geometry parameters in card3 when calculating downward or upward transmittance(or radiance),because of no any illustration about this issue in the user manual guide.
How to calculate downward and upward transmittance(radiance),respectively,with modtran4?
if someone knows it, please help me, thanks!
Thanks again!
Topic how to creat a file from L0 to L1 with code? By lwk1542 Date 2018-04-27 00:29
thank you very very very much!
Topic how to creat a file from L0 to L1 with code? By lwk1542 Date 2018-04-26 14:48
Dear developers!
    I want to know the whole processing via reading the code, but i cant find any related code. Is it secret code?
i have one image (.HDF formate) contains latitude layer,longitude layer and band layers. Is there any related python function can convert this file from HDF to geotiff,like ENVI/IDL “Envi_doit,'envi_register_doit'” function.

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill