Jpp  18.0.1-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
makedeclinationtable.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 '''Create magnetic declination table from UTM coordinates in degrees
3 Requires `pip install docopt numpy utm`
4 
5 Usage:
6  makedeclinationtable.py <easting> <northing> <zone> <letter>
7 
8 Arguments:
9  easting UTM Easting of the site
10  northing UTM Northing of the site
11  zone UTM zone
12  letter UTM letter
13 '''
14 from docopt import docopt
15 import requests
16 import json
17 import utm
18 
19 #convert date to timestamp (float).
20 #Taken from https://stackoverflow.com/questions/8777753/converting-datetime-date-to-utc-timestamp-in-python
21 
22 from datetime import datetime, date, timezone
23 import calendar
24 def gettimestamp(year, month, day):
25  d = date(year, month, day)
26  ts = calendar.timegm(d.timetuple())
27  dt = datetime.utcfromtimestamp(ts)
28  fts = dt.replace(tzinfo=timezone.utc).timestamp()
29  return int(fts)
30 
31 args = docopt(__doc__, version='0.1')
32 easting = args['<easting>']
33 northing = args['<northing>']
34 zone = args['<zone>']
35 letter = args['<letter>']
36 latitude, longitude = utm.to_latlon(float(easting), float(northing), int(zone), letter)
37 print("#lat long",latitude,longitude)
38 
39 model = 'IGRF' #data for 1590-2024
40 day = 1
41 
42 for year in range(2000,2025,1):
43  for month in range(1,13,1):
44  x = requests.get('https://www.ngdc.noaa.gov/geomag-web/calculators/calculateDeclination?lat1='+str(latitude) + \
45  '&lon1='+str(longitude) + \
46  '&model='+model + \
47  '&startYear='+str(year) + \
48  '&startMonth='+str(month) + \
49  '&startDay='+str(day) + \
50  '&resultFormat=json')
51  y = json.loads(x.text)
52  result = y['result'][0]
53  declination = result['declination']
54  print(gettimestamp(year,month, day), declination)
55 
print
Definition: JConvertDusj.sh:44
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $