acolite / acolite_mr

ACOLITE_MR: Atmospheric correction for aquatic applications of metre-scale satellites (obsolete)
GNU General Public License v3.0
10 stars 3 forks source link

NaN's when trying to process worldview 2 L1B #2

Closed rsawtell closed 4 years ago

rsawtell commented 4 years ago

Hi, I'm trying to process WorldView 2 L1B data. I've made a series of changes to read in the metadata, which seems to work ok. But I only get valid rhot values and rhos are all NaN.

For reference, the changes I have made so far:

In get_rtoa.py, added the following line so 0 data near the edges of the images is not used in the rhod step (the sort puts the masked values at the end so they get excluded: data = masked_array(data,mask=data==0)

In parse_metadata.py, I removed EARLIESTACQTIME from the metadata_tags list and then added the following: node = xmldoc.getElementsByTagName("EARLIESTACQTIME") if len(node)==0: node = xmldoc.getElementsByTagName("FIRSTLINETIME") if len(node) > 0: metadata["EARLIESTACQTIME"] = node[0].firstChild.nodeValue

further down, i had to change wave = rsr_convolute(rsr[band_names[b]]['wave'], rsr[band_names[b]]['wave'], band_rsr, band_wave) to wave = rsr_convolute(rsr[band_names[b]]['wave'], rsr[band_names[b]]['wave'], band_rsr, rsr[band_names[b]]['wave']) otherwise the resulting array was all 0's because of a scale mismatch between band_wave and rsr[band_names[b]]['wave'].

In read_band.py, I changed the if statement pertaining to filetypes to: if fnmatch.fnmatch(file,'*.TIF') or fnmatch.fnmatch(file,'*.NTF'):

Finally, in worldview_ac.py I changed the wave_hyper linspace command to: wave_hyper = np.linspace(wave_range[0],wave_range[1],int(round(((wave_range[1]-wave_range[0])/wave_step)+2))) to match other similar parts of the code in order to avoid a floating point precision induced error.

The NaN's seem to be introduced by the romix calculations LUT interpolation

PONDER-LUT-201704-MOD1 0.001 0.008611496190067283 0 0 PONDER-LUT-201704-MOD2 0.001 0.00861746820812758 0 0 2020-08-20T13:48:43 - Fitted model C, band pair COASTAL:COASTAL, taua 550: 0.001

I also added a few extra printouts for the rgi interpolator which seems to create the NaN's:

rgi: 18 [0.39 0.41 0.44 0.47 0.51 0.55 0.61 0.67 0.75 0.865 1.04 1.24 1.55 1.61 1.66 2.1 2.25 2.4 ] 25.499999999999986 4.900000000000006 20.5 0.001

ret: [0.15438205 0.12730977 0.09611435 0.07363125 0.05272035 0.03864505 0.02522028 0.01714201 0.01079992 0.00604626 0.00288662 0.00142513 0.00058602 0.00050421 0.00044658 nan nan nan]

The NaN values then propagate down to ds_att['romix'] resulting in the entire output being NaN.

acolite commented 4 years ago

This was caused by NaNs in the LUTs for the lowest AOT values in certain conditions. The interpolation then returned NaN values as well. I believe the last commit should fix this. I made the changes back in July but never committed them. Hope this helps!

rsawtell commented 4 years ago

Confirmed it is no longer outputting NaN's. Thanks.