Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing- ValueError: Longitude is out of range [-180, 180] #19

Open
Anshita1Saxena opened this issue Mar 26, 2023 · 11 comments
Open

Facing- ValueError: Longitude is out of range [-180, 180] #19

Anshita1Saxena opened this issue Mar 26, 2023 · 11 comments

Comments

@Anshita1Saxena
Copy link

Hi authors,

I tried to clone your project in my cluster, with the pre-trained model and tried to run it, however, I am facing the issue of ValueError: Longitude 436.3453766449724 is out of range [-180, 180]

Environment Details:
NAME="Rocky Linux"
VERSION="8.7 (Green Obsidian)"
ID_LIKE="rhel centos fedora"

Details of setup:-
Since the cluster doesn't support the conda environment, I installed all the libraries with their latest version in virtualenv. I am attaching the libraries version file here. requirements.txt

Data Set and pre-trained model details:
Train Dataset
Inference Dataset
Pre-trained Model
I am using these files:- config_new.json and weights_new.pth

Details of execution:-

  1. After installing and running the pre-trained model, at the histogram plot generation step, it was observed that numpy=1.24 which doesn't support np.int but support np.int_, given that your repository is built on numpy==1.19.2 and using np.int which is removed from numpy==1.24, I changed this in code at lines 28,55 in /project/60025/anshita/ClimateNet/climatenet/track_events.py Source: https://stackoverflow.com/a/74946903
    After this change, it worked fine.
  2. When I ran the project again, it halt with this error- ValueError: Longitude 436.3453766449724 is out of range [-180, 180] in this file- /project/60025/anshita/ClimateNet/climatenet/analyze_events.py at line 192. Also, when I tried to check the values of the latitudes and longitudes, I found that all the values are not within this range.
    Here are the values for pos1 and pos2 (highlighted in yellow color and marked as red for perceptible purposes):

image

In my humble opinion, these values should be scaled by code. Please provide your advice and kind suggestions.
Here the example.py file for your reference example.zip

Please let me know in case you need further details of how I am running your code or any configuration-related details. I will wait and appreciate your attention to this issue.
Appreciate your response at the earliest.

Thank You.

Best regards,
Anshita Saxena

@andregraubner
Copy link
Owner

Hello Anshita,
thanks a lot for reaching out!

The values of pos1 and pos2 you print seem to be correct and as expected, since those are simply the pixel positions (for which these values are normal).
Line 192 now turns them into the appropriate lat/lon before computing the haversine distances:
distances = np.array([hs.haversine(pixel_to_degree(pos1), pixel_to_degree(pos2)) for pos1, pos2 in zip(termination_centroids, genesis_centroids)])
Since you're getting an error, I expect there's something going wrong in the pixel_to_degree function (line 31). Can you share event_masks.shape, which gets used there? I suspect there's some issue with the dimensions.

Best
Andre

@Anshita1Saxena
Copy link
Author

Hi Andre,

Heartily appreciate your response. Now, I got that you are normalizing the pixel values to that range through pixel_to_degree(). Here is the shape of event_masks: 768
Here is the output screenshot for reference:
pixel_to_degree

I will wait for your further advice and suggestions on this.

Thank You.

Best regards,
Anshita Saxena

@andregraubner
Copy link
Owner

Hello Anshita,

can you share how you print the shape of the event_masks? I'm surprised that it's just a single number, I'd expect it to be a three-dimensional array... In case you're printing event_masks.shape[1] now, can you please share what just event_masks.shape produces?

Best
Andre

@Anshita1Saxena
Copy link
Author

Anshita1Saxena commented Mar 27, 2023

Hi Andre,

Appreciate your help here. Yes, I was printing event_masks.shape[1]. Here is the output of event_masks.shape: (61, 768, 1152)

I will wait for your further advice and suggestions on this.

Thank You.

Best regards,
Anshita Saxena

@andregraubner
Copy link
Owner

Hey Anshita,

thanks! This is puzzling, since these numbers look completely normal (and calling pixel_to_degree on the pos1 and pos2 values you shared should result in numbers in the required range). I'm not sure what's going on, can you show me the output of np.array([[pixel_to_degree(pos1), pixel_to_degree(pos2)] for pos1, pos2 in zip(termination_centroids, genesis_centroids)])? This is basically just the inputs to the haversine function which throws the error. If these are not strange, can you give me more details on which function exactly throws this ValueError? I assumed it was the haversine function but just want to make sure.

Best
Andre

@Anshita1Saxena
Copy link
Author

Anshita1Saxena commented Mar 27, 2023

Hi Andre,

Thanks. Here is what I got the values for pos1 and pos2. Please find the attached output file. Expected_outputs.txt

Yes, you are right, this is a haversine function. I am just pasting the lines of code from where I am getting this ValueError for our reference-
function_code

I will wait for your further advice and suggestions on this.

Thank You.

Best regards,
Anshita Saxena

@andregraubner
Copy link
Owner

Thank you!

This helps, it seems like there is really an issue with the pixel_to_degree function. I'll check with Lukas and get back to you as soon as possible.

Best
Andre

@Anshita1Saxena
Copy link
Author

Hi Andre,

Sure. I will wait for your response. Thanks for your reply.

Thank You.

Best regards,
Anshita Saxena

@Anshita1Saxena
Copy link
Author

Hi Andre,

I tried to debug this issue and found that we have written '+180' term instead '-180' term for pos[2]. Isn't it '-180'?
image
Example:-
pos=(444.4273699539777, 820.3052052639117)=(pos[0], pos[1])
pos[0] * 180.0 / event_masks.shape[1] - 90 ------> We got 14.16266483 which is expected and within the range [-180, 180]
pos[1] * 360 / event_masks.shape[2] + 180 ------> We got 436.34537664 which is out of range [-180, 180] and if we put pos[1] * 360 / event_masks.shape[2] - 180 ------> We will get 76.34537664 which is within the range [-180, 180].

Wanted to confirm you that are these the expected value, if yes, may I open the pull request for this change and merge it?

I will wait and appreciate your attention to this issue.
Appreciate your response at the earliest.

Thank You.

Best regards,
Anshita Saxena

@Anshita1Saxena
Copy link
Author

Anshita1Saxena commented Mar 30, 2023

Hi Andre,

I just wanted to append the results directory also for the validation of your side. These plots are generated after I performed the above change in code.

Could you please have look at the plots and confirm whether these are expected based on the functionality? Please find the attachments.

I am new to this project and currently trying to build my understanding of it.

genesis_frequency_results.zip
global_frequency_results.zip
termination_frequency_results.zip
histogram_lifetime.zip

In positions, it printed these values attached in this file:
positions_values.txt

I will wait and appreciate your attention to this issue.
Appreciate your response at the earliest.

Thank You.

Best regards,
Anshita Saxena

@Anshita1Saxena
Copy link
Author

Any news @andregraubner ?

Thank You.

Best regards,
Anshita Saxena

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants