Alexander-Barth / APTDecoder.jl

Decoder for the Automatic Picture Transmission protocol used by some weather satellites in Julia
MIT License
12 stars 3 forks source link

Question about using SatelliteToolbox for APTDecoder #1

Open sasha-intheair opened 3 years ago

sasha-intheair commented 3 years ago

Hello,

I have a question about producing georeferenced APT images using APTDecoder. I am new to Julia and to most programming, but georeferenced NOAA APT images are crucial for a new research project I'm currently working on, and it seems to me that APTDecoder has the ability to produce them. I followed the instructions on this github to install APTDecoder, and I was following the example decoding process here: https://github.com/Alexander-Barth/APTDecoder.jl/blob/master/examples/APTDecoder.ipynb

When it came to acquiring the NOAA satellite's TLEs, Alexander suggests this line of code:

tles = SatelliteToolbox.read_tle("weather-20190825.txt")

Which I adapted (for my satellite pass time on September 2nd 2021) to:

tles = SatelliteToolbox.read_tle("weather-20210902.txt")

However, instead of the TLE element array received by Alexander, I get:

ERROR: SystemError: opening file "weather-20210902.txt": No such file or directory

I tried different dates and played around with the syntax of the txt file name, but to no avail. Without TLEs, I don't think APTDecoder can georeference my NOAA images. Any help and advice is much appreciated.

Sasha

Alexander-Barth commented 3 years ago

Hi Sacha,

You can get a current TLE data from this address: https://www.celestrak.com/NORAD/elements/weather.txt

The function APTDecoder.get_tle(:weather) (https://github.com/Alexander-Barth/APTDecoder.jl/blob/master/src/georef.jl#L53) allows you to download and read TLEs programmatically. This function would update this file once day.

You can call it like this:

tles = APTDecoder.get_tle(:weather).

Sometimes I noticed an slight error in the geo-referenced image (see the southern UK coast). I don't what kind of level of accuracy you would need (for my purposes it is enough ;-)) .

E79rp2QX0AMyuaK

Alexander-Barth commented 3 years ago

I just updated the notebook with additional information. Most part of the notebook is about the signal processing. If you are just interested in the results it is sufficient to load the wav files and look at the cells after # decode to image.

sasha-intheair commented 3 years ago

Hi Alexander,

Thank you so much for your help, and for pointing out where to get current TLE information.

Apologies in advance if this is a silly follow up question, I'm still making my way into Julia and to coding more generally.

I tried using:

tles = APTDecoder.get_tle(:weather).

After I press 'return' the cursor just hovers below the line, without adding or generating anything.

However as you suggested, I also tried going here: https://www.celestrak.com/NORAD/elements/weather.txt and downloading the data into a txt file that I stored in the directory that is accessed by Julia. I named the file correctly and this time when I entered:

tles = SatelliteToolbox.read_tle("weather-20210908.txt")

The TLE elements loaded.

Using your example here https://github.com/Alexander-Barth/APTDecoder.jl/blob/master/examples/APTDecoder.ipynb, I made it all the way through the signal processing steps (which were fascinating!) and I successfully decoded the raw image. Then I reached step 95:

In [95]:

starttime = APTDecoder.starttimename(wavname)

TLEs are downloaded if omited

Alon,Alat,Adata = APTDecoder.georeference(channelA,satellite_name,datatime,starttime; tles=tles);

┌ Info: Downloading file 'EOP_IAU1980.TXT' from ' https://datacenter.iers.org/data/latestVersion/223_EOP_C04_14.62-NOW.IAU1980223.txt' with cURL. └ @ RemoteFiles /home/abarth/.julia/packages/RemoteFiles/Suit7/src/download.jl:53

More specifically, after 'Alon,Alat,Adata = APTDecoder.georeference(channelA,satellite_name,datatime,starttime; tles=tles);' I got:

ERROR: MethodError: no method matching

init_orbit_propagator(::Type{Val{:sgp4}}, ::SatelliteToolbox.SatelliteToolboxTLE.TLE) Closest candidates are: init_orbit_propagator(::Val{:sgp4}, ::SatelliteToolbox.SatelliteToolboxTLE.TLE; sgp4_gc) at /Users/sashacakes/.julia/packages/SatelliteToolbox/ZDGTT/src/orbit/propagators/api/sgp4.jl:35 Stacktrace: [1] georeference(data::SubArray{Float64, 2, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, UnitRange{Int64}}, true}, satellite_name::String, datatime::Vector{Float64}, starttime::Dates.DateTime; eop::Nothing, tles::Vector{SatelliteToolbox.SatelliteToolboxTLE.TLE}) @ APTDecoder ~/.julia/dev/APTDecoder/src/georef.jl:106 [2] top-level scope @ REPL[66]:1

I tried moving onward to:

APTDecoder.plot(Alon,Alat,Adata)

but received:

ERROR: UndefVarError: Alon not defined

Stacktrace: [1] top-level scope @ REPL[67]:1

I am sorry for another long message, but if you have time I would be so grateful for your help.

Best wishes,

Sasha

Le mer. 8 sept. 2021 à 20:51, Alexander Barth @.***> a écrit :

I just updated the notebook with additional information. Most part of the notebook is about the signal processing. If you are just interested in the results it is sufficient to load the wav files and look at the cells after # decode to image.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Alexander-Barth/APTDecoder.jl/issues/1#issuecomment-915523961, or unsubscribe https://github.com/notifications/unsubscribe-auth/APU7DPFQWX6EGHPEAFEKB5TUA65DFANCNFSM5DULWOIQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Dr. Sasha Engelmann (she/her) Lecturer in GeoHumanities Royal Holloway University of London www.sashaengelmann.com instagram: @sasha_intheair twitter: @sashacakes +44 7833367353

Alexander-Barth commented 3 years ago

These are not at all silly questions :-) In APTDecoder, I am using the package SatelliteToolbox and the function calls have changed slightly in this package. I just updated APTDecoder so that it works well with the latest version of SatelliteToolbox. Can you update your version of APTDecoder? The error ERROR: MethodError: no method matching init_orbit_propagator(::Type{Val{:sgp4}}, ::SatelliteToolbox.SatelliteToolboxTLE.TLE) should go away.

If you installed APTDecdoder with Pkg.develop, you can update with the shell command git pull. If you do not have git install, you can also use the following Julia commands to remove and reinstall APTDecoder:

using Pkg
Pkg.rm("APTDecoder")
Pkg.add(url="https://github.com/Alexander-Barth/APTDecoder.jl")

After I press 'return' the cursor just hovers below the line, without adding or generating anything.

Indeed, in Jupyter notebook, to execute a cell you can use Alt-Return or Control-Return.

sasha-intheair commented 3 years ago

Hi Alexander,

Thanks very much again for your help.

I uninstalled and re-installed APTDecoder using Julia and now the MethodError for using SatelliteToolbox has gone away.

I was able to process a recent NOAA 18 wavefile recording into raw and georeferenced images- here they are copied below.

[image: CubicSDR_20210902_110035_137913_raw.png] [image: CubicSDR_20210902_11035_137913_Channel B Georeferenced.png] [image: CubicSDR_20210902_110035_137913_Channel A GeoReferenced.png] I have a few questions about the georeferenced images: first, why this colour scheme? I know NOAA satellite images are always in grayscale and different APT decoders have different ways of assigning 8 bit values to pixels, but why do the images change into bright colours when they are referenced to a map in APTDecoder?

Second, there was an interesting warning in this part of the process:

julia> APTDecoder.plot(Alon,Alat,Adata)

sys:1: MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3. Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading']. This will become an error two minor releases later. [ Info: Downloading file 'lsmask_5min_l.bin' from ' https://raw.githubusercontent.com/matplotlib/basemap/v1.2.2rel/lib/mpl_toolkits/basemap/data/lsmask_5min_l.bin' with cURL.

There are some words here that seem to refer to 'shading' and 'color' but there is also a warning. Could you clarify what this means?

Third, which map projection is used for the georeferenced Channel A and B images?

Fourth, the georeferenced images are quite a bit lower in quality than the raw image. Why is this the case? Is it possible to preserve the image quality while also georeferencing?

I will stop there, but thanks so much again for your help and time.

Best,

Sasha

Le jeu. 9 sept. 2021 à 20:12, Alexander Barth @.***> a écrit :

These are not at all silly questions :-) In APTDecoder, I am using the package SatelliteToolbox and the function calls have changed slightly in this package. I just updated APTDecoder so that it works well with the latest version of SatelliteToolbox. Can you update your version of APTDecoder? The error ERROR: MethodError: no method matching init_orbit_propagator(::Type{Val{:sgp4}}, ::SatelliteToolbox.SatelliteToolboxTLE.TLE) should go away.

If you installed APTDecdoder with Pkg.develop, you can update with the shell command git pull. If you do not have git install, you can also use the following Julia commands to remove and reinstall APTDecoder:

using Pkg Pkg.rm("APTDecoder") Pkg.add(url="https://github.com/Alexander-Barth/APTDecoder.jl")

After I press 'return' the cursor just hovers below the line, without adding or generating anything.

Indeed, in Jupyter notebook, to execute a cell you can use Alt-Return or Control-Return.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Alexander-Barth/APTDecoder.jl/issues/1#issuecomment-916365934, or unsubscribe https://github.com/notifications/unsubscribe-auth/APU7DPADA267KNXVJQEA32DUBEBJVANCNFSM5DULWOIQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Dr. Sasha Engelmann (she/her) Lecturer in GeoHumanities Royal Holloway University of London www.sashaengelmann.com instagram: @sasha_intheair twitter: @sashacakes +44 7833367353

sasha-intheair commented 3 years ago

Here are the images that I didn't attach properly in the message above!

CubicSDR_20210902_110035_137913_raw

CubicSDR_20210902_110035_137913_Channel A GeoReferenced

CubicSDR_20210902_11035_137913_Channel B Georeferenced

Alexander-Barth commented 3 years ago
  1. This is this color map setting cmap (here RdYlBu_r). By getting the raw data, you can use a different color map if you like (including gray scale). By calling colorbar() you see the mapping between the numbers and colors.
  2. you can ignore it for now. This matplotlib documentation has more information about the pcolormesh function.
  3. the axis of the plot are directly lon / lat WSG84 (no projection). I am not really familiar with map projection in Julia. (https://xkcd.com/977/ :-) )
  4. maybe you can tune the dpi option of savefig https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html ?

If you want to customize the plots (color map, resolution, ...) , I would suggest you to just get the data with the lon/lat arrays so that you can more easily adjust your setting.

The captured data is very good ! Oddly you have a gray/black and white area for lon > 0. Can you call clf() to clear the figures?

sasha-intheair commented 3 years ago

Hi Alexander, Thanks very much for these tips- it sounds like changing colours and increasing the resolution of the georeferenced images might be possible. This is crucial for my purposes- I need to control the colour scheme as well as generate georeferenced images in the same resolution (or close) as the raw data. Since I am not a programmer, when you say 'I would suggest you to just get the data wiht the lon/lat arrays so that you can more easily adjust your setting' do you mean that in addition to saving the 'raw data' (i.e. the raw grayscale png image) there is a way to save arrays of latitudinal and longitudinal points that correspond to the raw data? Since each pixel in the raw image data is about 4km wide / long, does this mean that APTDecoder can generate an array list of lat / long points that correspond to each raw datapoint and its location? Apologies if I'm mis-interpreting what you wrote above. Best wishes, Sasha

PS: another set of images decoded today with APTDecoder

CubicSDR_20210328_102741_137913 Channel B Georeferenced CubicSDR_20210328_102741_137913_Channel A georeferenced CubicSDR_20210328_102741_137913_raw

Alexander-Barth commented 3 years ago

does this mean that APTDecoder can generate an array list of lat / long points that correspond to each raw datapoint and its location?

Yes, this is exactly right. Note that the function APTDecoder.makeplots allows you to already change the colormap cmap and the resolution dpi:

https://github.com/Alexander-Barth/APTDecoder.jl/blob/master/src/plot.jl#L30

If you need to have more control on the plots, then you would probably need to copy the body of this function and adapt it to your needs and it may indeed require some programming. This is for example a very good introduction to Julia
https://www.youtube.com/watch?v=4igzy3bGVkQ .

Going back to the original question: the variables lonA, latA are the arrays with the longitude and latitude of the A channel (and likewise for the B channel) and indeed you could save them to files.