X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 24 Jan 2017 11:04 AM by  anon
Problem with idlpy executing a simple ENVI task
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
24 Jan 2017 11:04 AM
    Hi all, i have an working IDL code to elaborate the TOA reflectance reading the metadata file MTL.txt. The asset is Landsat 8. Now, i am trying to execute the same code from python, using idlpy and IDL.run('expression') sintax. Here my code: from idlpy import IDL #i also tryed from idlpy import * # passing parameters to IDL function IDL.root_path = root_path #the directory where the MTL.txt file is saved IDL.TOA_Dir = TOA_Dir #the directory where will be saved the toa_files IDL.subdir = subdir #both root_path and TOA_DIR have the same subdirectory, named subdir. IDL.MTLfile = MTLfile #the name of the MTL.txt file IDL.ms_toa_filename = ms_toa_filename #the name of the toa file for the bands 1-7 IDL.pan_toa_filename = pan_toa_filename #the name of the toa file for the band 8 # start Envi application IDL.run('e = ENVI(/HEADLESS)') IDL.run('COMPILE_OPT IDL2') # open all L8 file by reading the L8filename_MTL.txt file. IDL.run('File = Filepath(MTLfile, Root_Dir = root_path, SUBDIR = [subdir])') IDL.run('Raster = e.OpenRaster(File)') # Get the radiometric calibration task from the catalog of ENVI tasks IDL.run('Task1=ENVITask("RadiometricCalibration")') # select calibration type # TOA reflectance include the atmospheric correction IDL.run('Task1.CALIBRATION_TYPE = "Top-of-Atmosphere Reflectance"') # set the task option for band 1-7 IDL.run('Task1.INPUT_RASTER = Raster[0]') # specify the output file IDL.run('Output_ms = Filepath(ms_toa_filename, Root_Dir = TOA_Dir, SUBDIR = [subdir])') IDL.run('Task1.OUTPUT_RASTER_URI = Output_ms)') # execute the task IDL.run('Task1.Execute') IDL.run('Task2=ENVITask("RadiometricCalibration")') IDL.run('Task2.CALIBRATION_TYPE = "Top-of-Atmosphere Reflectance"') # set the task option for band 8 IDL.run('Task1.INPUT_RASTER = Raster[1]') # specify the output file IDL.run('Output_pan = Filepath(pan_toa_filename, Root_Dir = TOA_Dir, SUBDIR = [subdir])') IDL.run('Task2.OUTPUT_RASTER_URI = Output_pan)') # execute the task IDL.run('Task2.Execute') # close IDL IDL.run('exit') The problem is that i can execute the program, no error is provide, everything seems to work properly, but the expected output are not producted. It works and do nothig. The same code executed from idl console works. Here for wholeness a similar code to calculate the ndvi from the mtl.txt file that works properly: # passing parameters to IDL function IDL.MTLfile = MTLfile IDL.root_path = root_path IDL.subdir = subdir IDL.ndvifilename = ndvi_filename IDL.ndvi_path = ndvi_path # start Envi application IDL.run('e = ENVI(/HEADLESS)') IDL.run('COMPILE_OPT IDL2') # Open the sceneID_MTL.txt file IDL.run('File = Filepath(MTLfile, Root_Dir = root_path, SUBDIR = [subdir])') IDL.run('Raster = e.OpenRaster(File)') # Get the task from the catalog of ENVITasks IDL.run('Task=ENVITask("SpectralIndex")') # Define inputs IDL.run('Task.INDEX = "Normalized Difference Vegetation Index') IDL.run('Task.INPUT_RASTER = Raster[0]') # select only the ms layer # Define outputs IDL.run('Output = Filepath(ndvifilename, Root_Dir = ndvi_path)') IDL.run('Task.OUTPUT_RASTER_URI = Output') # Execute the task IDL.run('Task.Execute') # Close all IDL.run('exit') Thank you in advance for any feedback.

    Deleted User



    New Member


    Posts:
    New Member


    --
    25 Jan 2017 02:34 AM
    I solved the problem: At this line IDL.run('Task1.OUTPUT_RASTER_URI = Output_ms)') the brachet closes without been opened. There is a system to keep track into python code of similar syntax errors when running IDL commands through the IDL.run('expression') ? Thank you.
    You are not authorized to post a reply.