Skip to content

Commit

Permalink
update pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Nov 21, 2024
1 parent 5303d53 commit f4b7119
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ncl/ncl_entries/great_circle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
}
],
"source": [
"from astropy.coordinates.representation import CartesianRepresentation, UnitSphericalRepresentation\n",
"from astropy.coordinates.representation import UnitSphericalRepresentation\n",
"from astropy import units\n",
"\n",
"lat = 40.0150\n",
"lon = -105.2705\n",
"\n",
"spherical_coords = UnitSphericalRepresentation(lat=lat*units.deg, lon=lon*units.deg)\n",
"spherical_coords = UnitSphericalRepresentation(lat=lat * units.deg, lon=lon * units.deg)\n",
"cart_coords = spherical_coords.to_cartesian()\n",
"print(f\"X = {cart_coords.x.value}\")\n",
"print(f\"Y = {cart_coords.y.value}\")\n",
Expand Down
18 changes: 10 additions & 8 deletions ncl/receipts/great_circle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@
"metadata": {},
"outputs": [],
"source": [
"#import geocat.datafiles as gdf\n",
"import geocat.datafiles as gdf\n",
"import numpy as np\n",
"from astropy.coordinates.representation import CartesianRepresentation, UnitSphericalRepresentation\n",
"from astropy.coordinates.representation import UnitSphericalRepresentation\n",
"from astropy import units\n",
"\n",
"css2c_data = gdf.get('applications_files/ncl_outputs/css2c_output.txt')\n",
Expand All @@ -168,15 +168,17 @@
"source": [
"## Collect Latitude and Longtiude Pairs\n",
"lat_lon = []\n",
"for lat in range(-90, 90+1):\n",
" for lon in range(-180, 180+1):\n",
"for lat in range(-90, 90 + 1):\n",
" for lon in range(-180, 180 + 1):\n",
" lat_lon.append((lat, lon))\n",
"\n",
"## Calculate Cartesian coordinates\n",
"astropy_css2c = {}\n",
"for i, pair in enumerate(lat_lon):\n",
" lat, lon = pair\n",
" spherical_coords = UnitSphericalRepresentation(lat=lat*units.deg, lon=lon*units.deg)\n",
" spherical_coords = UnitSphericalRepresentation(\n",
" lat=lat * units.deg, lon=lon * units.deg\n",
" )\n",
" cart_coords = spherical_coords.to_cartesian()\n",
" astropy_css2c[pair] = cart_coords.xyz.value"
]
Expand Down Expand Up @@ -249,9 +251,9 @@
"source": [
"for key in ncl_css2c.keys():\n",
" if key in astropy_css2c.keys():\n",
" assert abs(ncl_css2c[key][0]- astropy_css2c[key][0]) < 0.000005\n",
" assert abs(ncl_css2c[key][1]- astropy_css2c[key][1]) < 0.000005\n",
" assert abs(ncl_css2c[key][2]- astropy_css2c[key][2]) < 0.000005"
" assert abs(ncl_css2c[key][0] - astropy_css2c[key][0]) < 0.000005\n",
" assert abs(ncl_css2c[key][1] - astropy_css2c[key][1]) < 0.000005\n",
" assert abs(ncl_css2c[key][2] - astropy_css2c[key][2]) < 0.000005"
]
}
],
Expand Down

0 comments on commit f4b7119

Please sign in to comment.