Questions about aeroprofile sets

166 views
Skip to first unread message

jiaqiang...@gmail.com

unread,
Jun 2, 2015, 6:07:28 AM6/2/15
to py...@googlegroups.com
Hi
    I'm a student learner of both python and 6S. And now I met some problems with parameter setting of aero_profile.
    1. I checked 6SV page and tried some test run online. I noticed that there are trivial differences in parameter requirement between 6SV and Py6S. When setting aeroprofile, 6SV requires Aerosol Mode and AOT whereas Py6S requires predefined aerosol mode and aerosol layer with arguments of 'height' and 'AOT'. The problem is, I do not know anything about AOT height ( I extracted AOT data from Modis). How could I cope with this? For now, I just use 10 km for default height.
    2. I need to run 6S for each pixel thus I wrote my script with several loops. When running the script, I found that the layer of aerosol will accumulate. The layer I added for a former run will remain in a next run. I tried all the method (such as delattr, del) i could and found that only restarting ipython could eliminate these layers. And restarting could not be a solution as I have to finish all the loops. I knew little about class and attributes in python. I only tried to delete attributes, like: 
s= SixS()
...
delattr (s, 'aero_profile')
delattr(SIxS(), 'aero_profile')

also tried to delete variable:
del s
del s.aero_profile

But when I run 
s.aero_profile = AeroProfile_UserProfile(AeroProfile.Continent)
I get all layers back!

    Now I don't know what to do next
    And hope anyone could help me with this!
    Many thanks!!!
                             Jia Qiang




Robin Wilson

unread,
Jun 2, 2015, 6:18:02 AM6/2/15
to py...@googlegroups.com
Hi Jia,

1. Can you show me the code you're using to set the aerosol profile in Py6S? You should be able to set it just using the aerosol type and AOT, for example:

s.aero_profile = AeroProfile.PredefinedType(AeroProfile.Maritime)

s.aot550 = 0.2

2.
Can you show the code that you're using to add the layers? Just so I can check exactly what you're doing. I assume you're using the UserProfile.add_layer() function? Although you can't delete these layers at the moment, you should be able to create them from scratch each time by running the original assignment again. For example, see the code at http://py6s.readthedocs.org/en/latest/params.html#Py6S.AeroProfile.UserProfile: running the first line (
s.aeroprofile = AeroProfile.UserProfile(AeroProfile.Maritime)
Should clear the previous layers and set it up again with no layers.

From the combination of your two questions I have a suspicion you might be using the UserProfile option when you don't actually need to: if you just want to set an aerosol type (eg. Maritime, Urban etc) and an AOT then you can just use the code that I gave in the answer to 1) above.

Hope that helps,

Robin
--
You received this message because you are subscribed to the Google Groups "Py6S" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py6s+uns...@googlegroups.com.
To post to this group, send email to py...@googlegroups.com.
Visit this group at http://groups.google.com/group/py6s.

dald...@ud.ac.ae

unread,
Feb 10, 2019, 6:29:35 AM2/10/19
to Py6S
Hello Robin, 

hope you are doing great.

actually, I'm facing the same problem. I keep changing the aerosols profile but outputs don’t change, and when I open the output text document the aerosols profile had been assigned to maritime even if I assigned it to desert in the code. Following is my code…..

I really appreciate your help.

 
Diena

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 20 15:37:14 2019
@author: daldogom
"""
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 15 10:43:23 2018
@author: daldogom
"""
from Py6S import *
import math
import pandas as pd
from datetime import datetime
from dateutil.relativedelta import relativedelta
import os
import pickle
import xlsxwriter

os.chdir(r'C:\Users\daldogom\Desktop\DMSAT-1 Diena\TermTwo\LUTs')
os.listdir('.')
## BULID UP LUTS ##
s = SixS()
lat= 30.697971
lon= 70.116106
time=10
mon=12
day =1
eff="3"
model="Continental"
aot=1.5
        
##LIST TO APPEND##
outputs = []
## atmospheric correction ##
s.atmos_corr = AtmosCorr.NoAtmosCorr()
                           
## Set the altitudes ##
s.altitudes.set_sensor_satellite_level()
s.altitudes.set_target_sea_level
                            
## ATMOSPHERIC PROFILE ##
s.atmos_profile = AtmosProfile.FromLatitudeAndDate(24.254, "2001-1-1")
                            
## SENSOR AND VIEWING GEOMETRY ##
s.geometry = Geometry.Landsat_TM()
s.aot550 = aot
s.geometry.month = mon
s.geometry.day = day
s.geometry.gmt_decimal_hour = 12
s.geometry.latitude = lat
s.geometry.longitude = lon
band='1'
## LANDSAT_TM BANDS ##                            
s.wavelength = Wavelength(PredefinedWavelengths.LANDSAT_TM_B3)
    ## GROUND REFLECTANCE ##
s.ground_reflectance = GroundReflectance.HomogeneousLambertian(0.4)
   
## AEROSOL PROFILE ##
n= s.aeroprofile = AeroProfile.PredefinedType(AeroProfile.BiomassBurning)
## create a workbook and add a worksheet with date and time ##
workbook = xlsxwriter.Workbook('delet22' +'.xlsx')
worksheet = workbook.add_worksheet()
                   
## Add a bold format to use to highlight cells ##
bold = workbook.add_format({'bold': 1})
                   
## Write some data headers ##
worksheet.write('A1', 'Month', bold)
worksheet.write('B1', 'Day', bold)
worksheet.write('C1', 'Time', bold)
worksheet.write('D1', 'Band', bold)
worksheet.write('E1', 'Effective Raduis', bold)
worksheet.write('F1', 'Radiance', bold)
worksheet.write('G1', 'AOD', bold)
worksheet.write('H1', 'AOT', bold)
worksheet.write('I1', 'Model', bold)
worksheet.write('J1', 'Latitude', bold)
worksheet.write('K1', 'Longitude', bold)                      
                           
s.run ()
                            
## GETTING OUTPUTS ##
output = s.outputs.pixel_radiance
aod = s.outputs.optical_depth_total.total
output3 = s.outputs.write_output_file('delet22'  + ".txt")

                           
## APPENDING RESULTS ##
outputs.append(mon)
outputs.append(day)
outputs.append(time)
outputs.append(band)
outputs.append(eff)
outputs.append(output)
outputs.append(aod)
outputs.append(aot)
outputs.append(model)
outputs.append(lat)
outputs.append(lon)                     
                           
## Start from the first cell below the headers ##
row = 1
col = 0                           
for n in (outputs):
    worksheet.write_number (row, col, mon)
    worksheet.write_number (row, col + 1, day)
    worksheet.write_number (row, col + 2, time)   
    worksheet.write_string (row, col + 3, band)
    worksheet.write_string (row, col + 4, eff)
    worksheet.write_number (row, col + 5, output)
    worksheet.write_number (row, col + 6, aod)
    worksheet.write_number (row, col + 7, aot)
    worksheet.write_string (row, col + 8, model)
    worksheet.write_number (row, col + 9, lat)
    worksheet.write_number (row, col + 10, lon)
row += 1
   
workbook.close()
s= SixS()
...

del n
del s.aero_profile

Robin Wilson

unread,
Feb 10, 2019, 1:43:07 PM2/10/19
to py...@googlegroups.com
Hi,

I think it's just a typo in the following line:

n= s.aeroprofile = AeroProfile.PredefinedType(AeroProfile.BiomassBurning)

It should be s.aero_profile rather than s.aeroprofile. (I'd also suggest removing the `n=` bit, as that shouldn't be necessary).

Robin
--
You received this message because you are subscribed to the Google Groups "Py6S" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py6s+uns...@googlegroups.com.
To post to this group, send email to py...@googlegroups.com.

dald...@ud.ac.ae

unread,
Feb 12, 2019, 7:44:32 AM2/12/19
to Py6S
Thanks Robin, appreciated. 
Reply all
Reply to author
Forward
0 new messages