ropensci / MODIStsp

An "R" package for automatic download and preprocessing of MODIS Land Products Time Series
https://docs.ropensci.org/MODIStsp
GNU General Public License v3.0
155 stars 51 forks source link

scale/offset Day_view_angle #205

Closed itrebs closed 4 years ago

itrebs commented 4 years ago

I am wondering which scale/offset was applied for Day_view_angle? Normally it should be -65, but the angle I get when I klick "apply scale" does not make sense (it is negative sometimes).

lbusett commented 4 years ago

Hi @itrebs ,

could you please tell us which MODIS product you are working with? Also, it would be really helpful if you could save your processing options to a json file from the GUI and paste here its contents.

Lorenzo

itrebs commented 4 years ago

alright, here it is:

{ "sel_prod": "Surf_Temp_Daily_1Km (M*D11A1)", "sensor": "Both", "prod_version": "6", "start_date": "2011-01-01", "end_date": "2018-12-31", "bandsel": [1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0], "indexes_bandsel": 0, "quality_bandsel": [0, 0, 0, 0, 0, 0, 0, 0], "start_x": 30, "end_x": 30, "start_y": 10, "end_y": 10, "user": XXX, "password": XXX, "use_aria": false, "download_server": "http", "download_range": "full", "proj": "Native", "output_proj4": "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs", "out_res_sel": "Native", "out_res": "Native", "full_ext": "Define Custom Area", "resampling": "near", "out_format": "GTiff", "ts_format": "R rasterStack", "compress": "None", "nodata_change": "No", "scale_val": "Yes", "delete_hdf": "Yes", "reprocess": "No", "bbox": [14238120.3, -1389321.1, 14238164.3, -1389293.2], "out_folder": "L:\Dpts\ERIN\ENVISION\REMOTE\_Common\Ivonne Trebs \MODIS\MOD11\HS\LST_2011_2015", "out_folder_mod": "L:\Dpts\ERIN\ENVISION\REMOTE\_Common\Ivonne Trebs\MODIS\MOD11\HS\LST_2011_2015", "MODIStspVersion": "1.3.9", "custom_indexes": [] }

From: "Lorenzo Busetto" notifications@github.com To: "ropensci/MODIStsp" MODIStsp@noreply.github.com Cc: "itrebs" ivonne.trebs@list.lu, "Mention" mention@noreply.github.com Date: 04/06/2020 12:19 Subject: Re: [ropensci/MODIStsp] scale/offset Day_view_angle (#205)

Hi @itrebs ,

could you please tell us which MODIS product you are working with? Also, it would be really helpful if you could save your processing options to a json file from the GUI and paste here its contents.

Lorenzo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

lbusett commented 4 years ago

@itrebs

MODIStsp seems to apply the "theorically" correct scale and offset according to MODIS metadata at https://lpdaac.usgs.gov/products/mod11a1v006/,

that suggests that a -65 offset should be applied to the angles data. However, this seems to make no sense, since as you mentioned it can lead to negative angles... Is there a different way to interpret that table, in your opinion?

Lorenzo

lbusett commented 4 years ago

Ok, checking here:

https://lpdaac.usgs.gov/documents/118/MOD11_User_Guide_V6.pdf

at page 17, it says:

Note that the

Day_view_time and Night_view_time are in local solar time, which is the UTC time plus grid’s longitude in degrees / 15 degrees (in hours, +24 if local solar time < 0 or -24 if local solar time >= 24). The data day in the name of all the daily MOD11A1 files is in UTC so the data day in local solar time at each grid may be different from the data day in UTC by one day. The scale factor and offset for Day_view_angle and Night_view_angle in C6 Level-3 MODIS LST products have been changed so that a negative sign of the viewing angle means MODIS viewing the grid from east. The view zenith angle itself is always a positive number, the zenith angle from nadir

HTH

itrebs commented 4 years ago

Hi Lorenzo,

thanks for your feedback. So there seems to be a difference between view angle and view zenith angle. For me it seems that in MODIStsp something else than the offset of -65 was applied. I paste an example below:

NaN NaN -48 0 25 25 -60 0 2 2 NaN NaN NaN NaN NaN NaN -41 0 35 35 -55 0 14 14 -64 0 -11 0 NaN NaN NaN NaN

Left side is the output of MODIStsp if I apply the offset automatically. Right column are the values when I apply the offset of -65 manually (do not press apply scale/offset) in MODIStsp. So that means, all negative values are now zero. Maybe what MODIStsp calculates is the view angle and not vza?

Please let me know what you think.

Ivonne

From: "Lorenzo Busetto" notifications@github.com To: "ropensci/MODIStsp" MODIStsp@noreply.github.com Cc: "itrebs" ivonne.trebs@list.lu, "Mention" mention@noreply.github.com Date: 15/06/2020 23:50 Subject: Re: [ropensci/MODIStsp] scale/offset Day_view_angle (#205)

Ok, checking here:

https://lpdaac.usgs.gov/documents/118/MOD11_User_Guide_V6.pdf

at page 17, it says:

Note that the

Day_view_time and Night_view_time are in local solar time, which is the UTC time plus grid’s longitude in degrees / 15 degrees (in hours, +24 if local solar time < 0 or -24 if local solar time >= 24). The data day in the name of all the daily MOD11A1 files is in UTC so the data day in local solar time at each grid may be different from the data day in UTC by one day. The scale factor and offset for Day_view_angle and Night_view_angle in C6 Level-3 MODIS LST products have been changed so that a negative sign of the viewing angle means MODIS viewing the grid from east. The view zenith angle itself is always a positive number, the zenith angle from nadir

HTH

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

lbusett commented 4 years ago

Ok, now I see the issue... MODIStsp saves those datasets as Unsigned Byte (that is correct if offset is NOT applied because the valid range is 0-130, and unsigned would only allow 0-128), but if the offset is applied, they should be saved as Signed, otherwise negative values will be set to 0.... Ouch ! Did not notice that yesterday because I was checking the rasters BEFORE saving them to TIFF.

Thanks for pointing this out! I'll try to fix it as soon as possible (and see if there are other products that may share the same problem). In the meantime, applying the offset manually is your best option

Lorenzo

lbusett commented 4 years ago

@itrebs

forget the last message - that not seem to be the problem. I need a clarification about your last message. You mention that :

NaN NaN -48 0 25 25 -60 0 2 2 NaN NaN NaN NaN NaN NaN -41 0 35 35 -55 0 14 14 -64 0 -11 0 NaN NaN NaN NaN

Left side is the output of MODIStsp if I apply the offset automatically. Right column are the values when I apply the offset of -65 manually (do not press apply scale/offset) in MODIStsp.

It seems to me then that the behaviour when you select "apply scale/offset" (left side) is therefore correct (offset is applied) and we get negative values. It is not clear to me how you obtained the "right side" results instead. You say that you applied the offset "manually". What do you mean with that?

Lorenzo

itrebs commented 4 years ago

Hi Lorenzo,

with manually I mean that I select "no" in the apply scale/offset button of MODIStsp and then I subtract a value of -65 afterwards in my processing code. From the manual is reads that vza is not negative, but should always be between 0 and 65.

Best,

Ivonne

From: "Lorenzo Busetto" notifications@github.com To: "ropensci/MODIStsp" MODIStsp@noreply.github.com Cc: "itrebs" ivonne.trebs@list.lu, "Mention" mention@noreply.github.com Date: 16/06/2020 10:44 Subject: Re: [ropensci/MODIStsp] scale/offset Day_view_angle (#205)

@itrebs

forget the last message - that not seem to be the problem. I need a clarification about your last message. You mention that :

  NaN NaN
  -48 0
  25 25
  -60 0
  2 2
  NaN NaN
  NaN NaN
  NaN NaN
  -41 0
  35 35
  -55 0
  14 14
  -64 0
  -11 0
  NaN NaN
  NaN NaN

  Left side is the output of MODIStsp if I apply the offset
  automatically.
  Right column are the values when I apply the offset of -65 manually
  (do not
  press apply scale/offset) in MODIStsp.

It seems to me then that the behaviour when you select "apply scale/offset" (left side) is therefore correct (offset is applied) and we get negative values. It is not clear to me how you obtained the "right side" results instead. You say that you applied the offset "manually". What do you mean with that?

Lorenzo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

lbusett commented 4 years ago

From the manual is reads that vza is not negative, but should always be between 0 and 65

I do not think so. The manual seem to indicate that the negative sign indicates wether observation is from the East or from the West (whatever it means). So, you can have values between -65 and 65, with the magnitude indicating angle, and sign indicating "direction". When you apply the offest "manually", it seems that you are truncating somehow the values to zero. What are the values BEFORE you do the calculation (i.e., the values that you get form MODIStsp when apply scale/offset is on "No")? Maybe you are saving to a wrong data type?

Lorenzo

itrebs commented 4 years ago

Hi Lorenzo,

you are right, I had a problem in my code :-( .... Now I am getting the same numbers as you. But I do not understand, because the manual says that "The view zenith angle itself is always a positive number, the zenith angle from nadir. In Table 9 the range of 0-130 is given. Do I have to multiply my negative values with -1 then?

Sorry for making this trouble, but finally you helped me a lot!

Ivonne

From: "Lorenzo Busetto" notifications@github.com To: "ropensci/MODIStsp" MODIStsp@noreply.github.com Cc: "itrebs" ivonne.trebs@list.lu, "Mention" mention@noreply.github.com Date: 16/06/2020 11:16 Subject: Re: [ropensci/MODIStsp] scale/offset Day_view_angle (#205)

  From the manual is reads that vza is not negative, but should always
  be between 0 and 65

I do not think so. The manual seem to indicate that the negative sign indicates wether observation is from the East or from the West (whatever it means). So, you can have values between -65 and 65, with the magnitude indicating angle, and sign indicating "direction". When you apply the offest "manually", it seems that you are truncating somehow the values to zero. What are the values BEFORE you do the calculation (i.e., the values that you get form MODIStsp when apply scale/offset is on "No")? Maybe you are saving to a wrong data type?

Lorenzo

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

lbusett commented 4 years ago

My understanding is that if you are only interested in the "bare angle" irrespective of the "viewing direction" stuff, you just have to take the absolute value of the values you get after applying the offset.

Lorenzo