miniwinwm / WMM_Tiny

A tiny implementation of the World Magnetic Model to calculate magnetic variation. This project is actively maintained.
MIT License
24 stars 7 forks source link

Faulty results on arduino due #4

Closed mjsneijders closed 2 years ago

mjsneijders commented 2 years ago

Running the following code using your WMM_Tiny library on an Arduino Due results in an output of -4.80 degrees, while the calculator on https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#declination returns 2 degrees E.

do you have any idea where this almost 2.5 times difference comes from? it must have something to do with the negative latitude..... when i run using positive latitude and compare with the website calculator, the results look fine

code:

  uint8_t year = 22;
  uint8_t month = 3;
  uint8_t day = 4;

  double longitude = 52.964357;
  double latitude = -4.779369;  
  float Declination; 

  Serial.print("Longitude = "); Serial.println(longitude,6); 
  Serial.print("Latitude = ");  Serial.println(latitude,6); 
  Serial.println((String)"On date = "+ day + "-" + month + "-"  + year + "\n"); 

  wmm_init();  
  float wmmdate=wmm_get_date( year,  month,  day);
  E0000(latitude, longitude, wmmdate, &Declination); 

  Serial.println();
  Serial.println((String)"The calculated geomagnetic declination is: " + Declination + " degrees");

output:

Longitude = 52.964357
Latitude = -4.779369
On date = 4-3-22

The calculated geomagnetic declination is: -4.80 degrees
mjsneijders commented 2 years ago

never mind, i must have had my blond genes playing up... lat/lon reversed

miniwinwm commented 2 years ago

Thanks for the interest in the library anyway. I'll get on to fixing the typo.

On Sat, 5 Mar 2022 at 09:43, mjsneijders @.***> wrote:

never mind, i must have had my blond genes playing up... lat/lon reversed

— Reply to this email directly, view it on GitHub https://github.com/miniwinwm/WMM_Tiny/issues/4#issuecomment-1059731080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQN3EX53TEXD76KQUBTOTLU6MUEHANCNFSM5P7OR6NA . 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.

You are receiving this because you are subscribed to this thread.Message ID: @.***>