geodesymiami / insarmaps

3 stars 0 forks source link

switch min/max when changing scale from displacement to velocity #43

Closed falkamelung closed 3 years ago

falkamelung commented 3 years ago

On a similar token as

https://github.com/geodesymiami/insarmaps/issues/42

when changing from velocity to displacement and vice versa, it would be better if the max and min in the colorscale is adjusted according to the time period covered. I.e. the map display should look more-or-less the scale but the numbers change. It is not really high priority but I am giving it a high-priority as it looks very easy to do (just need to a do a velocity-to-displacement conversion calculation)

image image

This is what the swict from velocity to displacement should producce:

image
stackTom commented 3 years ago

I have implemented this, please check it. However, I don't understand why it should be 80. Please check this link: https://insarmaps.miami.edu/start/19.7039/-155.1071/8.1013?flyToDatasetCenter=false&startDataset=S1_IW23_124_0060_0063_20141213_20191229&pointLat=19.39984&pointLon=-155.30419&minScale=-1280&maxScale=1280&startDate=20180420&endDate=20180725&colorscale=velocity

If we are 1280 with velocity, shouldn't displacement be 4866.7?

From from april 20 2018 to july 25 2018 there are 96 days. 96 / 365 = 0.26301369863 of a year.

Velocity scale values * 0.26301369863 = new displacement scale values

and 1280 * 0.26301369863 = 4866.7, not 80. If my logic is correct, please close this issue as the code is online. If my logic is wrong, please explain to me how to do it properly.

stackTom commented 3 years ago

Never mind. I misunderstood your initial post. What's currently on the server is wrong. I will fix it and get back to you.

stackTom commented 3 years ago

Fixed. Please try it. I spent like 2 hours on it and ended up doing the wrong thing. The true solution was actually very simple and took me like 10 minutes, like you said, once I understood what you really wanted.

However, when switching from scale 1280 velocity to displacement, the scale changes to 336.7. So please double check, but the dataset doesn't switch colors, exactly like you wanted, so I believe 336.7 is correct and not 80.

falkamelung commented 3 years ago

This works great now.

We do have for both velocity and displacement default max/min settings. So it would be even better if instead of switching to [-8.6 8.6] it would switch to the nearest of our defaults, [-10.0 10.0] in this case. Of course, there will be a change in the colors, but nothing dramatic.

stackTom commented 3 years ago

Just to make sure I understand. You want, when switching to velocity or displacement, to change the color scale to the nearest defaults. Aka the same nearest defaults we use for this functionality: https://github.com/geodesymiami/insarmaps/issues/12 ?

stackTom commented 3 years ago

Yes, we have defaults. But the logic we use to calculate those defaults isn't to just choose the nearest one. What it does it takes the minimum and maximum of the color scale. Then it chooses the greater of the absolute value of the min and max. It takes 50% of this value, call it x. Then it uses x to search the permissibleValues for the closest value to x. Here are the permissible values you told me to do:

[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 300, 400, 500, 600, 700, 800, 900, 1000];

Just making sure to use this same function that we use for setting the scale for datasets. Or do you want a new function that chooses that simply chooses the closest value?

stackTom commented 3 years ago

done. I just used the same logic for setting the color scale as we do for datasets (aka the 50% etc etc). If it is not correct, please update this issue and I'll write a custom function to just select the nearest and not use the 50% logic we currently have.

falkamelung commented 3 years ago

This is much better now, but there is still a small bug. If you start with displacement and switch to velocity, it adjusts the colorscale with the switch to displacement. That is the desired behavior. However, if you start with velocity and switch to displacement only the legend changes but not the colors. You need to go to the maxScale field end hit enter for the colors to change.

https://insarmaps.miami.edu/start/19.4287/-155.2043/11.2361?flyToDatasetCenter=false&startDataset=S1_IW12_087_0527_0531_20141116_20191226&pointLat=19.41179&pointLon=-155.27178&minScale=-5&maxScale=5&startDate=20180423&endDate=20180505&colorscale=displacement

https://insarmaps.miami.edu/start/19.4287/-155.2043/11.2361?flyToDatasetCenter=false&startDataset=S1_IW12_087_0527_0531_20141116_20191226&pointLat=19.41179&pointLon=-155.27178&minScale=-80&maxScale=80&startDate=20180423&endDate=20180505&colorscale=velocity
stackTom commented 3 years ago

done