kenfus / radiospectra

BSD 2-Clause "Simplified" License
0 stars 2 forks source link

Missing axes leads to wrong calculation of the freq_axis in callisto.py (IndexError: index 199 is out of bounds for axis 0 with size 50) #8

Closed SyleKu closed 3 years ago

SyleKu commented 3 years ago

When trying to do a background subtraction of the "_GAURI_20131012_04002059.fit" fits file, which has no axes in the file, it first leads to a "IndexError: list index out of range" Error.

This can easily be solved by adding these codes:

try except for the axes:

grafik

And setting None before the axes check for tm and fq:

grafik

After adding these missing codes it leads to the situation where tm and fq are None and it will try to calculate freq_axis (see line 334):

grafik

The error occurs on line 341, where it tries to access an index in freq_axis which doesn't exist, since the array length is too small (here the array length of freq_axis would be 50) and the value of right is 199:

grafik

Error message:

grafik

@Beckicious: Do you have any idea on how to solve this?

Note: I am using the radiospectra master branch for running the background subtraction.

Beckicious commented 3 years ago

Do we have to be able to work with CallistoSpectrograms that have no time or frequency axis?

ACsillaghy commented 3 years ago

I think there is some confusion about the axes. There are different ways to specify the axes. But to answer the question of Simon: I think there should always be an axis. The axis is either in one of the binary tables, or it should be constructed from the header information (and thus assumed to have equidistant values). If there is no context (freq / time) information, then there is no big reason to use CallistoSpectrogram at all.

SyleKu commented 3 years ago

When you check out the "_GAURI_20131012_040020_59.fit_" fits file, you will only see these information (since it doesn't have a second table for the frequencies):

grafik

I am not quite sure if we are able to construct the information about the frequencies (probably not), but we have the information about the time axis for sure.

Actually when checking out the callistoQuicklook images (http://soleil.i4ds.ch/solarradio/callistoQuicklooks/?date=20131012) we don't have an image there, so we really can skip fits files which doesn't have axis at all.

grafik

However, I would still suggest to put the try except clause around the "axes = fl[1]" code as I did in the first image but with the error information such as "Warning: Your provided fits file doesn't have axis information" (or something like that) just to keep the code clean, otherwise threads would crash at this point, since no exception is thrown there.

Currently the "callisto.py" file looks like this:

grafik

ACsillaghy commented 3 years ago

Dear Kushtrim

Did you check the contents of this file? Yes if there is no main array then it is pointless. But if you have an array and you have the frequency information in the header, then you should construct the axis based on this information.

Herzliche Grüsse André


Tel +41 76 330 2049 / Zoom 841 949 8036https://fhnw.zoom.us/j/8419498036

From: SyleKu notifications@github.com Reply to: i4Ds/radiospectra reply@reply.github.com Date: Wednesday, 10 March 2021 at 08:49 To: i4Ds/radiospectra radiospectra@noreply.github.com Cc: André Csillaghy andre.csillaghy@fhnw.ch, Comment comment@noreply.github.com Subject: Re: [i4Ds/radiospectra] Missing axes leads to wrong calculation of the freq_axis in callisto.py (IndexError: index 199 is out of bounds for axis 0 with size 50) (#8)

When you check out the "GAURI_20131012_040020_59.fit" fits file, you will only see these information (since it doesn't have a second table for the frequencies):

[Image removed by sender. grafik]https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5213937%2F110594175-c2428800-817c-11eb-9efd-3801cb62952b.png&data=04%7C01%7Candre.csillaghy%40fhnw.ch%7Ca21276f78dc64f93054c08d8e39906e4%7C9d1a5fc8321e4101ae63530730711ac2%7C0%7C0%7C637509593670340357%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=AzsLcKSgHZBibmSu6oNjUL8ERkKGn%2BbVM%2Fg26d9awj8%3D&reserved=0

I am not quite sure if we are able to construct the information about the frequencies (probably not), but we have the information about the time axis for sure.

Actually when checking out the callistoQuicklook images (http://soleil.i4ds.ch/solarradio/callistoQuicklooks/?date=20131012https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsoleil.i4ds.ch%2Fsolarradio%2FcallistoQuicklooks%2F%3Fdate%3D20131012&data=04%7C01%7Candre.csillaghy%40fhnw.ch%7Ca21276f78dc64f93054c08d8e39906e4%7C9d1a5fc8321e4101ae63530730711ac2%7C0%7C0%7C637509593670340357%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0EXGS8Y6xYOl2H4UNDGGgiyyz5gyVZFwO35JHfev%2BbE%3D&reserved=0) we don't have an image there, so we really can skip fits files which doesn't have axis at all.

[Image removed by sender. grafik]https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5213937%2F110591153-fddb5300-8178-11eb-8b28-9ebe1b3a3a6c.png&data=04%7C01%7Candre.csillaghy%40fhnw.ch%7Ca21276f78dc64f93054c08d8e39906e4%7C9d1a5fc8321e4101ae63530730711ac2%7C0%7C0%7C637509593670350314%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=JoDs7A8fcmq7xiHjXhvE6%2Fgn%2BVm4tjy2qapg%2B%2B6lVMQ%3D&reserved=0

However, I would still suggest to put the try except clause around the "axes = fl[1]" code as I did in the first image but with the error information such as "Warning: Your provided fits file doesn't have axis information" (or something like that) just to keep the code clean, otherwise threads would crash at this point, since no exception is thrown there.

Currently the "callisto.py" file looks like this:

[Image removed by sender. grafik]https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5213937%2F110593360-c1f5bd00-817b-11eb-8dc3-f7cf383c704b.png&data=04%7C01%7Candre.csillaghy%40fhnw.ch%7Ca21276f78dc64f93054c08d8e39906e4%7C9d1a5fc8321e4101ae63530730711ac2%7C0%7C0%7C637509593670350314%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=PyxKhSa6aBVzkAX4lr8ptjE6MLkOFhEL%2Fj4CDfvqf3U%3D&reserved=0

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fi4Ds%2Fradiospectra%2Fissues%2F8%23issuecomment-795038228&data=04%7C01%7Candre.csillaghy%40fhnw.ch%7Ca21276f78dc64f93054c08d8e39906e4%7C9d1a5fc8321e4101ae63530730711ac2%7C0%7C0%7C637509593670360275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=JY8V4wR0uGbdiInCyaznNqWBZj8L6vjLGmFeWk88vmE%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAEJMGOZKB6UG4SZVTE4VGWTTC4QADANCNFSM4YHNULBA&data=04%7C01%7Candre.csillaghy%40fhnw.ch%7Ca21276f78dc64f93054c08d8e39906e4%7C9d1a5fc8321e4101ae63530730711ac2%7C0%7C0%7C637509593670360275%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=OeC2ll1%2BcAKpd172wmV5Ow6XKIHaiCXCI3V4ZSYlF7I%3D&reserved=0.