From 9e7756f0616a5673f9876a4edf74522f819b3947 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 17 Dec 2024 13:16:12 -0700
Subject: [PATCH 01/14] csc2s receipt/entry
---
ncl/ncl_entries/great_circle.ipynb | 80 +++++++++++++++--
ncl/ncl_raw/great_circle.ncl | 20 +++++
ncl/receipts/great_circle.ipynb | 134 +++++++++++++++++++++++++++--
3 files changed, 221 insertions(+), 13 deletions(-)
diff --git a/ncl/ncl_entries/great_circle.ipynb b/ncl/ncl_entries/great_circle.ipynb
index b3c57426..18a51c27 100644
--- a/ncl/ncl_entries/great_circle.ipynb
+++ b/ncl/ncl_entries/great_circle.ipynb
@@ -16,7 +16,8 @@
"This section covers great circle functions from NCL:\n",
"\n",
"- [area_poly_sphere](https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml)\n",
- "- [css2c](https://www.ncl.ucar.edu/Document/Functions/Built-in/css2c.shtml)"
+ "- [css2c](https://www.ncl.ucar.edu/Document/Functions/Built-in/css2c.shtml)\n",
+ "- [csc2s](https://www.ncl.ucar.edu/Document/Functions/Built-in/csc2s.shtml)"
]
},
{
@@ -43,9 +44,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "1940855.984630871"
+ ]
+ },
+ "execution_count": 1,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"from pyproj import Geod\n",
"\n",
@@ -76,9 +88,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "X = -0.20171369272651396\n",
+ "Y = -0.7388354627678497\n",
+ "Z = 0.6429881376224998\n"
+ ]
+ }
+ ],
"source": [
"from astropy.coordinates.representation import UnitSphericalRepresentation\n",
"from astropy import units\n",
@@ -93,6 +115,54 @@
"print(f\"Z = {cart_coords.z.value}\")"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## csc2s\n",
+ "NCL's `csc2s` converts Cartesian coordaintes to spherical (latitude/longitude) coordinates on a unit sphere"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Grab and Go"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Latitude = 40.015\n",
+ "Longitude = -105.27049999999997\n"
+ ]
+ }
+ ],
+ "source": [
+ "from astropy.coordinates.representation import CartesianRepresentation, SphericalRepresentation\n",
+ "import numpy as np\n",
+ "\n",
+ "x = -0.20171369272651396\n",
+ "y = -0.7388354627678497\n",
+ "z = 0.6429881376224998\n",
+ "\n",
+ "cart_coords = CartesianRepresentation(x=x, y=y, z=z)\n",
+ "spherical_coords = cart_coords.represent_as(SphericalRepresentation)\n",
+ "\n",
+ "# convert latitude/longitude from radians to degrees\n",
+ "lat_deg = np.rad2deg(spherical_coords.lat.value)\n",
+ "lon_deg = (np.rad2deg(spherical_coords.lon.value) + 180) % 360 - 180 # keep longitude between -180 to 180\n",
+ "\n",
+ "print(f\"Latitude = {lat_deg}\")\n",
+ "print(f\"Longitude = {lon_deg}\")"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/ncl/ncl_raw/great_circle.ncl b/ncl/ncl_raw/great_circle.ncl
index b3093f69..1fdd9c05 100644
--- a/ncl/ncl_raw/great_circle.ncl
+++ b/ncl/ncl_raw/great_circle.ncl
@@ -83,3 +83,23 @@ do lat=-90,90
end
end do
end do
+
+; csc2s
+; Adapted from https://www.ncl.ucar.edu/Document/Functions/Built-in/csc2s.shtml
+
+; ncl -n csc2s.ncl >> csc2s_output.txt
+
+print("Cartesian X, Cartesian Y, Cartesian Z, Latitude (Degree), Longitude (Degree)")
+do lat=-90,90
+ do lon=-180,180
+ begin
+ cart = css2c(lat, lon)
+ ; determine a list of xyz coordinates based on lat/lon
+ x = cart(0,0)
+ y = cart(1,0)
+ z = cart(2,0)
+ sph = csc2s(x, y, z)
+ print(x + "," + y + "," + z + "," + sph(0,0) + "," + sph(1,0))
+ end
+ end do
+end do
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index 68300d1c..c00c9c86 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -25,7 +25,8 @@
"source": [
"## Functions covered\n",
"- [area_poly_sphere](https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml)\n",
- "- [css2c](https://www.ncl.ucar.edu/Document/Functions/Built-in/css2c.shtml)"
+ "- [css2c](https://www.ncl.ucar.edu/Document/Functions/Built-in/css2c.shtml)\n",
+ "- [csc2s](https://www.ncl.ucar.edu/Document/Functions/Built-in/csc2s.shtml)"
]
},
{
@@ -64,7 +65,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"id": "2ba99b37-a743-4776-bc7b-d5a08b977642",
"metadata": {},
"outputs": [],
@@ -133,7 +134,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"id": "35abde81-5843-4504-8e32-a137ee1aa094",
"metadata": {},
"outputs": [],
@@ -147,13 +148,13 @@
"css2c_data = np.loadtxt(css2c_data, delimiter=',', skiprows=6)\n",
"\n",
"lat_lon = tuple(map(tuple, (css2c_data[::, 0:2])))\n",
- "cart_values = css2c_data[::, 2:]\n",
+ "cart_values = tuple(css2c_data[::, 2:])\n",
"ncl_css2c = dict(zip(lat_lon, cart_values))"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"id": "ee104ea1-e287-4635-b404-5b06ccfb6949",
"metadata": {},
"outputs": [],
@@ -175,6 +176,56 @@
" astropy_css2c[pair] = cart_coords.xyz.value"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "399d047d-f22c-41cf-996d-d84e1f5b096c",
+ "metadata": {},
+ "source": [
+ "### csc2s"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "5ae18411-506d-455c-867e-50273bfff7e2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import geocat.datafiles as gdf\n",
+ "from astropy.coordinates.representation import CartesianRepresentation, SphericalRepresentation\n",
+ "import numpy as np\n",
+ "\n",
+ "#csc2s_data = gdf.get('applications_files/ncl_outputs/csc2s_output.txt')\n",
+ "csc2s_data = np.loadtxt(\"../ncl_raw/csc2s_output.txt\", delimiter=',', skiprows=6)\n",
+ "\n",
+ "cart_values = csc2s_data[::, 0:3]\n",
+ "lat_lon = tuple(map(tuple, (csc2s_data[::, 3:])))\n",
+ "ncl_csc2s = dict(zip(lat_lon, cart_values))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "043a0ec3-e0a2-4c6e-952d-1d459237a1f4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "## Calculate Spherical coordinates\n",
+ "def spherical_cart(x, y, z):\n",
+ " cart_coords = CartesianRepresentation(x=x, y=y, z=z)\n",
+ " spherical_coords = cart_coords.represent_as(SphericalRepresentation)\n",
+ " # convert latitude/longitude from radians to degrees\n",
+ " lat_deg = np.rad2deg(spherical_coords.lat.value)\n",
+ " lon_deg = (np.rad2deg(spherical_coords.lon.value) + 180) % 360 - 180 # keep longitude between -180 to 180\n",
+ " return (lat_deg, lon_deg)\n",
+ "\n",
+ "astropy_csc2s = {}\n",
+ "for xyz in cart_values:\n",
+ " x, y, z = xyz\n",
+ " lat_lon = spherical_cart(x, y, z)\n",
+ " astropy_csc2s[tuple(xyz)] = lat_lon"
+ ]
+ },
{
"cell_type": "markdown",
"id": "3237a0bffc6827fc",
@@ -204,10 +255,57 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"id": "74362fd9-0e9f-4cf9-91da-08cd81be625c",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "VALID:\n",
+ "\tBoulder, Boston, Houston: \n",
+ "\tncl:\t\t1940856\n",
+ "\tpython:\t\t1940855.984630871\n",
+ "\n",
+ "VALID:\n",
+ "\tFour Corners of Colorado: \n",
+ "\tncl:\t\t250007.6\n",
+ "\tpython:\t\t250007.81588628562\n",
+ "\n",
+ "VALID:\n",
+ "\tCaltech, Alberta, Greenwich, Paris, Madrid: \n",
+ "\tncl:\t\t11634800\n",
+ "\tpython:\t\t11634798.025760762\n",
+ "\n",
+ "VALID:\n",
+ "\tCrossing the Equator: \n",
+ "\tncl:\t\t114894.8\n",
+ "\tpython:\t\t114894.73868013734\n",
+ "\n",
+ "VALID:\n",
+ "\tCrossing the Prime Meridian: \n",
+ "\tncl:\t\t54450.39\n",
+ "\tpython:\t\t54450.41832867822\n",
+ "\n",
+ "VALID:\n",
+ "\tHalf of the World: \n",
+ "\tncl:\t\t255032000\n",
+ "\tpython:\t\t255031995.77390912\n",
+ "\n",
+ "INVALID:\n",
+ "\tSingle Point -> Invalid NCL: \n",
+ "\t\tncl:\t\t-127516000\n",
+ "\t\tpython:\t\t0.0\n",
+ "\n",
+ "VALID:\n",
+ "\tSingle Degree: \n",
+ "\tncl:\t\t9401.705\n",
+ "\tpython:\t\t9401.704877506347\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"for key in ncl_results.keys():\n",
" if key in python_results.keys() and key in python_results.keys():\n",
@@ -236,7 +334,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"id": "d5738d2d-5abe-4ed4-8e90-c42881c2bfb0",
"metadata": {},
"outputs": [],
@@ -247,6 +345,26 @@
" 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"
]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "90d7474d-60fb-4c22-8191-a120560174af",
+ "metadata": {},
+ "source": [
+ "### csc2s"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "53360a09-f1f3-4b0f-b7b4-9501aa5c92e1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "for i, key in enumerate(ncl_csc2s.keys()):\n",
+ " assert abs(key[0] - astropy_csc2s[list(astropy_csc2s.keys())[i]][0]) < 0.0005\n",
+ " assert abs(key[1] - astropy_csc2s[list(astropy_csc2s.keys())[i]][1]) < 0.0005"
+ ]
}
],
"metadata": {
From 26988cbd1320d29e136991d86a9e8167634aa46b Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 17 Dec 2024 13:26:55 -0700
Subject: [PATCH 02/14] pre-commit update
---
ncl/ncl_entries/great_circle.ipynb | 9 +++++++--
ncl/receipts/great_circle.ipynb | 12 +++++++++---
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/ncl/ncl_entries/great_circle.ipynb b/ncl/ncl_entries/great_circle.ipynb
index 18a51c27..92fa221c 100644
--- a/ncl/ncl_entries/great_circle.ipynb
+++ b/ncl/ncl_entries/great_circle.ipynb
@@ -145,7 +145,10 @@
}
],
"source": [
- "from astropy.coordinates.representation import CartesianRepresentation, SphericalRepresentation\n",
+ "from astropy.coordinates.representation import (\n",
+ " CartesianRepresentation,\n",
+ " SphericalRepresentation,\n",
+ ")\n",
"import numpy as np\n",
"\n",
"x = -0.20171369272651396\n",
@@ -157,7 +160,9 @@
"\n",
"# convert latitude/longitude from radians to degrees\n",
"lat_deg = np.rad2deg(spherical_coords.lat.value)\n",
- "lon_deg = (np.rad2deg(spherical_coords.lon.value) + 180) % 360 - 180 # keep longitude between -180 to 180\n",
+ "lon_deg = (\n",
+ " np.rad2deg(spherical_coords.lon.value) + 180\n",
+ ") % 360 - 180 # keep longitude between -180 to 180\n",
"\n",
"print(f\"Latitude = {lat_deg}\")\n",
"print(f\"Longitude = {lon_deg}\")"
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index c00c9c86..6a4ee398 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -192,10 +192,13 @@
"outputs": [],
"source": [
"import geocat.datafiles as gdf\n",
- "from astropy.coordinates.representation import CartesianRepresentation, SphericalRepresentation\n",
+ "from astropy.coordinates.representation import (\n",
+ " CartesianRepresentation,\n",
+ " SphericalRepresentation,\n",
+ ")\n",
"import numpy as np\n",
"\n",
- "#csc2s_data = gdf.get('applications_files/ncl_outputs/csc2s_output.txt')\n",
+ "# csc2s_data = gdf.get('applications_files/ncl_outputs/csc2s_output.txt')\n",
"csc2s_data = np.loadtxt(\"../ncl_raw/csc2s_output.txt\", delimiter=',', skiprows=6)\n",
"\n",
"cart_values = csc2s_data[::, 0:3]\n",
@@ -216,9 +219,12 @@
" spherical_coords = cart_coords.represent_as(SphericalRepresentation)\n",
" # convert latitude/longitude from radians to degrees\n",
" lat_deg = np.rad2deg(spherical_coords.lat.value)\n",
- " lon_deg = (np.rad2deg(spherical_coords.lon.value) + 180) % 360 - 180 # keep longitude between -180 to 180\n",
+ " lon_deg = (\n",
+ " np.rad2deg(spherical_coords.lon.value) + 180\n",
+ " ) % 360 - 180 # keep longitude between -180 to 180\n",
" return (lat_deg, lon_deg)\n",
"\n",
+ "\n",
"astropy_csc2s = {}\n",
"for xyz in cart_values:\n",
" x, y, z = xyz\n",
From f50554c7501e751eaa338be595cbbc2891dbe47b Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Thu, 16 Jan 2025 14:57:44 -0700
Subject: [PATCH 03/14] update receipt with edge cases
---
ncl/ncl_raw/great_circle.ncl | 2 +-
ncl/receipts/great_circle.ipynb | 129 ++++++++++++++++----------------
2 files changed, 67 insertions(+), 64 deletions(-)
diff --git a/ncl/ncl_raw/great_circle.ncl b/ncl/ncl_raw/great_circle.ncl
index 1fdd9c05..eff06a43 100644
--- a/ncl/ncl_raw/great_circle.ncl
+++ b/ncl/ncl_raw/great_circle.ncl
@@ -99,7 +99,7 @@ do lat=-90,90
y = cart(1,0)
z = cart(2,0)
sph = csc2s(x, y, z)
- print(x + "," + y + "," + z + "," + sph(0,0) + "," + sph(1,0))
+ print(lat + "," + lon + "," + x + "," + y + "," + z + "," + sph(0,0) + "," + sph(1,0))
end
end do
end do
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index 6a4ee398..d6490427 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -65,7 +65,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"id": "2ba99b37-a743-4776-bc7b-d5a08b977642",
"metadata": {},
"outputs": [],
@@ -134,7 +134,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"id": "35abde81-5843-4504-8e32-a137ee1aa094",
"metadata": {},
"outputs": [],
@@ -154,7 +154,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"id": "ee104ea1-e287-4635-b404-5b06ccfb6949",
"metadata": {},
"outputs": [],
@@ -186,7 +186,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"id": "5ae18411-506d-455c-867e-50273bfff7e2",
"metadata": {},
"outputs": [],
@@ -201,14 +201,16 @@
"# csc2s_data = gdf.get('applications_files/ncl_outputs/csc2s_output.txt')\n",
"csc2s_data = np.loadtxt(\"../ncl_raw/csc2s_output.txt\", delimiter=',', skiprows=6)\n",
"\n",
- "cart_values = csc2s_data[::, 0:3]\n",
- "lat_lon = tuple(map(tuple, (csc2s_data[::, 3:])))\n",
- "ncl_csc2s = dict(zip(lat_lon, cart_values))"
+ "input_lat_lon = tuple(map(tuple, csc2s_data[::, 0:2]))\n",
+ "cart_values = tuple(map(tuple, (csc2s_data[::, 2:5])))\n",
+ "output_lat_lon = tuple(map(tuple, (csc2s_data[::, 5:])))\n",
+ "ncl_csc2s = dict(zip(input_lat_lon, cart_values))\n",
+ "ncl_csc2s_input_output = dict(zip(input_lat_lon, output_lat_lon))"
]
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"id": "043a0ec3-e0a2-4c6e-952d-1d459237a1f4",
"metadata": {},
"outputs": [],
@@ -224,12 +226,11 @@
" ) % 360 - 180 # keep longitude between -180 to 180\n",
" return (lat_deg, lon_deg)\n",
"\n",
- "\n",
"astropy_csc2s = {}\n",
"for xyz in cart_values:\n",
" x, y, z = xyz\n",
" lat_lon = spherical_cart(x, y, z)\n",
- " astropy_csc2s[tuple(xyz)] = lat_lon"
+ " astropy_csc2s[lat_lon] = tuple(xyz)"
]
},
{
@@ -261,57 +262,10 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"id": "74362fd9-0e9f-4cf9-91da-08cd81be625c",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "VALID:\n",
- "\tBoulder, Boston, Houston: \n",
- "\tncl:\t\t1940856\n",
- "\tpython:\t\t1940855.984630871\n",
- "\n",
- "VALID:\n",
- "\tFour Corners of Colorado: \n",
- "\tncl:\t\t250007.6\n",
- "\tpython:\t\t250007.81588628562\n",
- "\n",
- "VALID:\n",
- "\tCaltech, Alberta, Greenwich, Paris, Madrid: \n",
- "\tncl:\t\t11634800\n",
- "\tpython:\t\t11634798.025760762\n",
- "\n",
- "VALID:\n",
- "\tCrossing the Equator: \n",
- "\tncl:\t\t114894.8\n",
- "\tpython:\t\t114894.73868013734\n",
- "\n",
- "VALID:\n",
- "\tCrossing the Prime Meridian: \n",
- "\tncl:\t\t54450.39\n",
- "\tpython:\t\t54450.41832867822\n",
- "\n",
- "VALID:\n",
- "\tHalf of the World: \n",
- "\tncl:\t\t255032000\n",
- "\tpython:\t\t255031995.77390912\n",
- "\n",
- "INVALID:\n",
- "\tSingle Point -> Invalid NCL: \n",
- "\t\tncl:\t\t-127516000\n",
- "\t\tpython:\t\t0.0\n",
- "\n",
- "VALID:\n",
- "\tSingle Degree: \n",
- "\tncl:\t\t9401.705\n",
- "\tpython:\t\t9401.704877506347\n",
- "\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"for key in ncl_results.keys():\n",
" if key in python_results.keys() and key in python_results.keys():\n",
@@ -340,7 +294,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"id": "d5738d2d-5abe-4ed4-8e90-c42881c2bfb0",
"metadata": {},
"outputs": [],
@@ -360,16 +314,65 @@
"### csc2s"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "fa9fb6d4-550b-4d61-85df-51b268a96256",
+ "metadata": {},
+ "source": [
+ "
\n",
+ "
Important Note
\n",
+ " In NCL, all the longitude coordinates for -90/+90 latitude produce the exact opposite longitude coordinate. For example, an input (-90, -179) produces an output of (-90, 1) and an input of (-90,13) produces an output (-90,-167).\n",
+ "\n",
+ "```\n",
+ "ncl 0> cart = css2c(-90, 87)\n",
+ "ncl 1> print(csc2s(cart(0,0), cart(1,0), cart(2,0)))\n",
+ "(0,0)\t-90\n",
+ "(1,0)\t-92.99999\n",
+ "```\n",
+ "And all latitude coordinates produce the a flipped longitude. For example, an input of (-89,-180) produces an output of (-89,180)\n",
+ "```\n",
+ "ncl 4> cart = css2c(89,180) \n",
+ "ncl 5> print(csc2s(cart(0,0), cart(1,0), cart(2,0)))\n",
+ "(0,0)\t89.00005\n",
+ "(1,0)\t-180\n",
+ "```\n",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "2e651572-aeb0-458f-9590-2ee6d2008235",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "for key in ncl_csc2s_input_output.keys():\n",
+ " try:\n",
+ " assert ncl_csc2s_input_output[key][0] == key[0]\n",
+ " assert ncl_csc2s_input_output[key][1] == key[1]\n",
+ " except Exception:\n",
+ " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
+ " # Expected places where input lat/lon will not match output lat/lon in NCL\n",
+ " # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
+ " # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
+ " assert False"
+ ]
+ },
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": null,
"id": "53360a09-f1f3-4b0f-b7b4-9501aa5c92e1",
"metadata": {},
"outputs": [],
"source": [
"for i, key in enumerate(ncl_csc2s.keys()):\n",
- " assert abs(key[0] - astropy_csc2s[list(astropy_csc2s.keys())[i]][0]) < 0.0005\n",
- " assert abs(key[1] - astropy_csc2s[list(astropy_csc2s.keys())[i]][1]) < 0.0005"
+ " try:\n",
+ " assert abs(key[0] - list(astropy_csc2s.keys())[i][0]) < 0.0005\n",
+ " assert abs(key[1] - list(astropy_csc2s.keys())[i][1]) < 0.0005\n",
+ " except Exception:\n",
+ " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
+ " # Expected places where input lat/lon will not match output lat/lon in NCL\n",
+ " assert False"
]
}
],
From f60a702297da964b58f1c4e309a943464ea1356b Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Thu, 16 Jan 2025 15:00:41 -0700
Subject: [PATCH 04/14] update pre-commit
---
ncl/receipts/great_circle.ipynb | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index d6490427..95f88e94 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -226,6 +226,7 @@
" ) % 360 - 180 # keep longitude between -180 to 180\n",
" return (lat_deg, lon_deg)\n",
"\n",
+ "\n",
"astropy_csc2s = {}\n",
"for xyz in cart_values:\n",
" x, y, z = xyz\n",
@@ -351,7 +352,10 @@
" assert ncl_csc2s_input_output[key][0] == key[0]\n",
" assert ncl_csc2s_input_output[key][1] == key[1]\n",
" except Exception:\n",
- " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
+ " if (\n",
+ " abs(ncl_csc2s_input_output[key][0]) != 90\n",
+ " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
+ " ):\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
@@ -370,7 +374,10 @@
" assert abs(key[0] - list(astropy_csc2s.keys())[i][0]) < 0.0005\n",
" assert abs(key[1] - list(astropy_csc2s.keys())[i][1]) < 0.0005\n",
" except Exception:\n",
- " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
+ " if (\n",
+ " abs(ncl_csc2s_input_output[key][0]) != 90\n",
+ " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
+ " ):\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" assert False"
]
From 6f9c00e818ce719821712210d88a56f717ebf7eb Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Thu, 16 Jan 2025 15:10:14 -0700
Subject: [PATCH 05/14] update ncl index
---
ncl/ncl_index/ncl-index-table.csv | 1 +
1 file changed, 1 insertion(+)
diff --git a/ncl/ncl_index/ncl-index-table.csv b/ncl/ncl_index/ncl-index-table.csv
index 05721145..097d4720 100644
--- a/ncl/ncl_index/ncl-index-table.csv
+++ b/ncl/ncl_index/ncl-index-table.csv
@@ -50,3 +50,4 @@ NCL Function,Description,Python Equivalent,Notes
`satvpr_temp_fao56 `__,"Compute saturation vapor pressure using temperature as described in FAO 56","``geocat.comp.saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-temp-fao56>`__
`satvpr_tdew_fao56 `__,"Compute actual saturation vapor pressure as described in FAO 56","``geocat.comp.actual_saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-tdew-fao56>`__
`satvpr_slope_fao56 `__," Compute the slope of the saturation vapor pressure curve as described in FAO 56","``geocat.comp.saturation_vapor_pressure_slope()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-slope-fao56>`__
+`csc2s `__,"Converts Cartesian coordinates on a unit sphere to spherical coordinates (lat/lon)","``astropy.CartesianRepresentation().represent_as(SphericalRepresentation)``",`example notebook <../ncl_entries/great_circle.ipynb#csc2s>`__
From 0182d95277b7b206e79fbc6729ea8cb963c214b7 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Thu, 16 Jan 2025 15:26:13 -0700
Subject: [PATCH 06/14] update index description
---
ncl/ncl_index/ncl-index-table.csv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ncl/ncl_index/ncl-index-table.csv b/ncl/ncl_index/ncl-index-table.csv
index 097d4720..8289499c 100644
--- a/ncl/ncl_index/ncl-index-table.csv
+++ b/ncl/ncl_index/ncl-index-table.csv
@@ -50,4 +50,4 @@ NCL Function,Description,Python Equivalent,Notes
`satvpr_temp_fao56 `__,"Compute saturation vapor pressure using temperature as described in FAO 56","``geocat.comp.saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-temp-fao56>`__
`satvpr_tdew_fao56 `__,"Compute actual saturation vapor pressure as described in FAO 56","``geocat.comp.actual_saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-tdew-fao56>`__
`satvpr_slope_fao56 `__," Compute the slope of the saturation vapor pressure curve as described in FAO 56","``geocat.comp.saturation_vapor_pressure_slope()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-slope-fao56>`__
-`csc2s `__,"Converts Cartesian coordinates on a unit sphere to spherical coordinates (lat/lon)","``astropy.CartesianRepresentation().represent_as(SphericalRepresentation)``",`example notebook <../ncl_entries/great_circle.ipynb#csc2s>`__
+`csc2s `__,"Converts Cartesian coordinates on a unit sphere to spherical coordinates (lat/lon)","``astropy.coordinates.representation``",`example notebook <../ncl_entries/great_circle.ipynb#csc2s>`__
From 2a41a5c737d80ab9802bc1d70069b7abff92ad85 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 21 Jan 2025 13:26:52 -0700
Subject: [PATCH 07/14] update to datafiles
---
ncl/ncl_entries/great_circle.ipynb | 42 +++++-------------------------
ncl/receipts/great_circle.ipynb | 19 +++++---------
2 files changed, 13 insertions(+), 48 deletions(-)
diff --git a/ncl/ncl_entries/great_circle.ipynb b/ncl/ncl_entries/great_circle.ipynb
index 92fa221c..5e5f1f42 100644
--- a/ncl/ncl_entries/great_circle.ipynb
+++ b/ncl/ncl_entries/great_circle.ipynb
@@ -44,20 +44,9 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "1940855.984630871"
- ]
- },
- "execution_count": 1,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"from pyproj import Geod\n",
"\n",
@@ -88,19 +77,9 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "X = -0.20171369272651396\n",
- "Y = -0.7388354627678497\n",
- "Z = 0.6429881376224998\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"from astropy.coordinates.representation import UnitSphericalRepresentation\n",
"from astropy import units\n",
@@ -132,18 +111,9 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Latitude = 40.015\n",
- "Longitude = -105.27049999999997\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"from astropy.coordinates.representation import (\n",
" CartesianRepresentation,\n",
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index 95f88e94..7047f7f8 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -198,8 +198,8 @@
")\n",
"import numpy as np\n",
"\n",
- "# csc2s_data = gdf.get('applications_files/ncl_outputs/csc2s_output.txt')\n",
- "csc2s_data = np.loadtxt(\"../ncl_raw/csc2s_output.txt\", delimiter=',', skiprows=6)\n",
+ "csc2s_data = gdf.get('applications_files/ncl_outputs/csc2s_output.txt')\n",
+ "csc2s_data = np.loadtxt(csc2s_data, delimiter=',', skiprows=6)\n",
"\n",
"input_lat_lon = tuple(map(tuple, csc2s_data[::, 0:2]))\n",
"cart_values = tuple(map(tuple, (csc2s_data[::, 2:5])))\n",
@@ -226,7 +226,6 @@
" ) % 360 - 180 # keep longitude between -180 to 180\n",
" return (lat_deg, lon_deg)\n",
"\n",
- "\n",
"astropy_csc2s = {}\n",
"for xyz in cart_values:\n",
" x, y, z = xyz\n",
@@ -330,7 +329,7 @@
"(0,0)\t-90\n",
"(1,0)\t-92.99999\n",
"```\n",
- "And all latitude coordinates produce the a flipped longitude. For example, an input of (-89,-180) produces an output of (-89,180)\n",
+ "And all latitude coordinates produce the a flipped longitude at +/-180 longitude. For example, an input of (-89,-180) produces an output of (-89,180)\n",
"```\n",
"ncl 4> cart = css2c(89,180) \n",
"ncl 5> print(csc2s(cart(0,0), cart(1,0), cart(2,0)))\n",
@@ -352,10 +351,7 @@
" assert ncl_csc2s_input_output[key][0] == key[0]\n",
" assert ncl_csc2s_input_output[key][1] == key[1]\n",
" except Exception:\n",
- " if (\n",
- " abs(ncl_csc2s_input_output[key][0]) != 90\n",
- " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
- " ):\n",
+ " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
@@ -374,11 +370,10 @@
" assert abs(key[0] - list(astropy_csc2s.keys())[i][0]) < 0.0005\n",
" assert abs(key[1] - list(astropy_csc2s.keys())[i][1]) < 0.0005\n",
" except Exception:\n",
- " if (\n",
- " abs(ncl_csc2s_input_output[key][0]) != 90\n",
- " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
- " ):\n",
+ " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
+ " # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
+ " # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
" assert False"
]
}
From 84818fa521064115784cd6fb568d781249b0c5a1 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 21 Jan 2025 13:30:13 -0700
Subject: [PATCH 08/14] update pre-commit
---
ncl/receipts/great_circle.ipynb | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index 7047f7f8..99635aeb 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -226,6 +226,7 @@
" ) % 360 - 180 # keep longitude between -180 to 180\n",
" return (lat_deg, lon_deg)\n",
"\n",
+ "\n",
"astropy_csc2s = {}\n",
"for xyz in cart_values:\n",
" x, y, z = xyz\n",
@@ -351,7 +352,10 @@
" assert ncl_csc2s_input_output[key][0] == key[0]\n",
" assert ncl_csc2s_input_output[key][1] == key[1]\n",
" except Exception:\n",
- " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
+ " if (\n",
+ " abs(ncl_csc2s_input_output[key][0]) != 90\n",
+ " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
+ " ):\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
@@ -370,7 +374,10 @@
" assert abs(key[0] - list(astropy_csc2s.keys())[i][0]) < 0.0005\n",
" assert abs(key[1] - list(astropy_csc2s.keys())[i][1]) < 0.0005\n",
" except Exception:\n",
- " if abs(ncl_csc2s_input_output[key][0]) != 90 and abs(ncl_csc2s_input_output[key][1]) != 180:\n",
+ " if (\n",
+ " abs(ncl_csc2s_input_output[key][0]) != 90\n",
+ " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
+ " ):\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
From 32bb1a98403d2720b7717cc8d55fde3da3a7a169 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Thu, 23 Jan 2025 15:02:39 -0700
Subject: [PATCH 09/14] update raw column headers
---
ncl/ncl_raw/great_circle.ncl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ncl/ncl_raw/great_circle.ncl b/ncl/ncl_raw/great_circle.ncl
index eff06a43..9144638f 100644
--- a/ncl/ncl_raw/great_circle.ncl
+++ b/ncl/ncl_raw/great_circle.ncl
@@ -89,7 +89,7 @@ end do
; ncl -n csc2s.ncl >> csc2s_output.txt
-print("Cartesian X, Cartesian Y, Cartesian Z, Latitude (Degree), Longitude (Degree)")
+print("Input Latitude (Degree), Input Longitude (Degree), Cartesian X, Cartesian Y, Cartesian Z, Output Latitude (Degree), Output Longitude (Degree)")
do lat=-90,90
do lon=-180,180
begin
From c812ec3e7d701222ca0ef729db2cf6f13d07909f Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Fri, 24 Jan 2025 14:00:15 -0700
Subject: [PATCH 10/14] test exception
---
ncl/receipts/great_circle.ipynb | 67 ++++++++++++++++++++++++++++-----
1 file changed, 58 insertions(+), 9 deletions(-)
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index 99635aeb..20554852 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -65,7 +65,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"id": "2ba99b37-a743-4776-bc7b-d5a08b977642",
"metadata": {},
"outputs": [],
@@ -134,7 +134,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"id": "35abde81-5843-4504-8e32-a137ee1aa094",
"metadata": {},
"outputs": [],
@@ -154,7 +154,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"id": "ee104ea1-e287-4635-b404-5b06ccfb6949",
"metadata": {},
"outputs": [],
@@ -186,7 +186,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"id": "5ae18411-506d-455c-867e-50273bfff7e2",
"metadata": {},
"outputs": [],
@@ -210,7 +210,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"id": "043a0ec3-e0a2-4c6e-952d-1d459237a1f4",
"metadata": {},
"outputs": [],
@@ -263,10 +263,57 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"id": "74362fd9-0e9f-4cf9-91da-08cd81be625c",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "VALID:\n",
+ "\tBoulder, Boston, Houston: \n",
+ "\tncl:\t\t1940856\n",
+ "\tpython:\t\t1940855.984630871\n",
+ "\n",
+ "VALID:\n",
+ "\tFour Corners of Colorado: \n",
+ "\tncl:\t\t250007.6\n",
+ "\tpython:\t\t250007.81588628562\n",
+ "\n",
+ "VALID:\n",
+ "\tCaltech, Alberta, Greenwich, Paris, Madrid: \n",
+ "\tncl:\t\t11634800\n",
+ "\tpython:\t\t11634798.025760762\n",
+ "\n",
+ "VALID:\n",
+ "\tCrossing the Equator: \n",
+ "\tncl:\t\t114894.8\n",
+ "\tpython:\t\t114894.73868013734\n",
+ "\n",
+ "VALID:\n",
+ "\tCrossing the Prime Meridian: \n",
+ "\tncl:\t\t54450.39\n",
+ "\tpython:\t\t54450.41832867822\n",
+ "\n",
+ "VALID:\n",
+ "\tHalf of the World: \n",
+ "\tncl:\t\t255032000\n",
+ "\tpython:\t\t255031995.77390912\n",
+ "\n",
+ "INVALID:\n",
+ "\tSingle Point -> Invalid NCL: \n",
+ "\t\tncl:\t\t-127516000\n",
+ "\t\tpython:\t\t0.0\n",
+ "\n",
+ "VALID:\n",
+ "\tSingle Degree: \n",
+ "\tncl:\t\t9401.705\n",
+ "\tpython:\t\t9401.704877506347\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"for key in ncl_results.keys():\n",
" if key in python_results.keys() and key in python_results.keys():\n",
@@ -295,7 +342,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"id": "d5738d2d-5abe-4ed4-8e90-c42881c2bfb0",
"metadata": {},
"outputs": [],
@@ -342,7 +389,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"id": "2e651572-aeb0-458f-9590-2ee6d2008235",
"metadata": {},
"outputs": [],
@@ -356,6 +403,7 @@
" abs(ncl_csc2s_input_output[key][0]) != 90\n",
" and abs(ncl_csc2s_input_output[key][1]) != 180\n",
" ):\n",
+ " print(Exception)\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
@@ -378,6 +426,7 @@
" abs(ncl_csc2s_input_output[key][0]) != 90\n",
" and abs(ncl_csc2s_input_output[key][1]) != 180\n",
" ):\n",
+ " print(Exception)\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
From 8eca1b3de1b9b35df57f31bb03a487d035027ecc Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Mon, 3 Feb 2025 14:53:01 -0700
Subject: [PATCH 11/14] spelling edits
---
ncl/ncl_entries/great_circle.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ncl/ncl_entries/great_circle.ipynb b/ncl/ncl_entries/great_circle.ipynb
index 5e5f1f42..17ed57ae 100644
--- a/ncl/ncl_entries/great_circle.ipynb
+++ b/ncl/ncl_entries/great_circle.ipynb
@@ -99,7 +99,7 @@
"metadata": {},
"source": [
"## csc2s\n",
- "NCL's `csc2s` converts Cartesian coordaintes to spherical (latitude/longitude) coordinates on a unit sphere"
+ "NCL's `csc2s` converts Cartesian coordinates to spherical (latitude/longitude) coordinates on a unit sphere"
]
},
{
From 32f39d3a7a0a26aec686ea24893e0224902c1885 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 4 Feb 2025 15:12:11 -0700
Subject: [PATCH 12/14] update pre-commit
---
ncl/ncl_index/ncl-index-table.csv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ncl/ncl_index/ncl-index-table.csv b/ncl/ncl_index/ncl-index-table.csv
index 1bc0d76d..50dcdaa7 100644
--- a/ncl/ncl_index/ncl-index-table.csv
+++ b/ncl/ncl_index/ncl-index-table.csv
@@ -51,4 +51,4 @@ NCL Function,Description,Python Equivalent,Notes
`satvpr_tdew_fao56 `__,"Compute actual saturation vapor pressure as described in FAO 56","``geocat.comp.actual_saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-tdew-fao56>`__
`satvpr_slope_fao56 `__," Compute the slope of the saturation vapor pressure curve as described in FAO 56","``geocat.comp.saturation_vapor_pressure_slope()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-slope-fao56>`__
`coriolis_param `__,"Calculate the Coriolis parameter","``metpy.calc.coriolis_parameter()``",`example notebook <../ncl_entries/meteorology.ipynb#coriolis-param>`__
-`csc2s `__,"Converts Cartesian coordinates on a unit sphere to spherical coordinates (lat/lon)","``astropy.coordinates.representation``",`example notebook <../ncl_entries/great_circle.ipynb#csc2s>`__
\ No newline at end of file
+`csc2s `__,"Converts Cartesian coordinates on a unit sphere to spherical coordinates (lat/lon)","``astropy.coordinates.representation``",`example notebook <../ncl_entries/great_circle.ipynb#csc2s>`__
From 96150048c8c0270715989ef69523a760d875066b Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 4 Feb 2025 15:59:12 -0700
Subject: [PATCH 13/14] update receipt check range
---
ncl/receipts/great_circle.ipynb | 73 +++++++--------------------------
1 file changed, 14 insertions(+), 59 deletions(-)
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index 20554852..c9a14b8c 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -65,7 +65,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
"id": "2ba99b37-a743-4776-bc7b-d5a08b977642",
"metadata": {},
"outputs": [],
@@ -134,7 +134,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": null,
"id": "35abde81-5843-4504-8e32-a137ee1aa094",
"metadata": {},
"outputs": [],
@@ -154,7 +154,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": null,
"id": "ee104ea1-e287-4635-b404-5b06ccfb6949",
"metadata": {},
"outputs": [],
@@ -186,7 +186,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": null,
"id": "5ae18411-506d-455c-867e-50273bfff7e2",
"metadata": {},
"outputs": [],
@@ -210,7 +210,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": null,
"id": "043a0ec3-e0a2-4c6e-952d-1d459237a1f4",
"metadata": {},
"outputs": [],
@@ -263,57 +263,10 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": null,
"id": "74362fd9-0e9f-4cf9-91da-08cd81be625c",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "VALID:\n",
- "\tBoulder, Boston, Houston: \n",
- "\tncl:\t\t1940856\n",
- "\tpython:\t\t1940855.984630871\n",
- "\n",
- "VALID:\n",
- "\tFour Corners of Colorado: \n",
- "\tncl:\t\t250007.6\n",
- "\tpython:\t\t250007.81588628562\n",
- "\n",
- "VALID:\n",
- "\tCaltech, Alberta, Greenwich, Paris, Madrid: \n",
- "\tncl:\t\t11634800\n",
- "\tpython:\t\t11634798.025760762\n",
- "\n",
- "VALID:\n",
- "\tCrossing the Equator: \n",
- "\tncl:\t\t114894.8\n",
- "\tpython:\t\t114894.73868013734\n",
- "\n",
- "VALID:\n",
- "\tCrossing the Prime Meridian: \n",
- "\tncl:\t\t54450.39\n",
- "\tpython:\t\t54450.41832867822\n",
- "\n",
- "VALID:\n",
- "\tHalf of the World: \n",
- "\tncl:\t\t255032000\n",
- "\tpython:\t\t255031995.77390912\n",
- "\n",
- "INVALID:\n",
- "\tSingle Point -> Invalid NCL: \n",
- "\t\tncl:\t\t-127516000\n",
- "\t\tpython:\t\t0.0\n",
- "\n",
- "VALID:\n",
- "\tSingle Degree: \n",
- "\tncl:\t\t9401.705\n",
- "\tpython:\t\t9401.704877506347\n",
- "\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"for key in ncl_results.keys():\n",
" if key in python_results.keys() and key in python_results.keys():\n",
@@ -342,7 +295,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": null,
"id": "d5738d2d-5abe-4ed4-8e90-c42881c2bfb0",
"metadata": {},
"outputs": [],
@@ -389,11 +342,12 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": null,
"id": "2e651572-aeb0-458f-9590-2ee6d2008235",
"metadata": {},
"outputs": [],
"source": [
+ "# Verify Latitude/Longitude Inputs match the Latitude/Longtiude Outputs\n",
"for key in ncl_csc2s_input_output.keys():\n",
" try:\n",
" assert ncl_csc2s_input_output[key][0] == key[0]\n",
@@ -417,16 +371,17 @@
"metadata": {},
"outputs": [],
"source": [
+ "# Verify conversions from cartesian coordinates to latitude/longtiude\n",
"for i, key in enumerate(ncl_csc2s.keys()):\n",
" try:\n",
" assert abs(key[0] - list(astropy_csc2s.keys())[i][0]) < 0.0005\n",
" assert abs(key[1] - list(astropy_csc2s.keys())[i][1]) < 0.0005\n",
" except Exception:\n",
" if (\n",
- " abs(ncl_csc2s_input_output[key][0]) != 90\n",
- " and abs(ncl_csc2s_input_output[key][1]) != 180\n",
+ " not math.isclose(abs(key[0]), 90) and not math.isclose(abs(key[1]), 180)\n",
" ):\n",
- " print(Exception)\n",
+ " print(abs(key[0] - list(astropy_csc2s.keys())[i][0]))\n",
+ " print(abs(key[1] - list(astropy_csc2s.keys())[i][1]))\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",
" # NCL produces flipped longitude value for +/-90 latitude, example: (90,-179)->(90,1)\n",
" # NCL produces flipped longitude value for all latitude values when longitude is 180, example: (79,-180)->(79,180)\n",
From 87d80fd5393fe1fb8bd67a34b522d7e5d5262b06 Mon Sep 17 00:00:00 2001
From: cyschneck <22159116+cyschneck@users.noreply.github.com>
Date: Tue, 4 Feb 2025 16:00:43 -0700
Subject: [PATCH 14/14] update pre-commit
---
ncl/receipts/great_circle.ipynb | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/ncl/receipts/great_circle.ipynb b/ncl/receipts/great_circle.ipynb
index c9a14b8c..fc96ae10 100644
--- a/ncl/receipts/great_circle.ipynb
+++ b/ncl/receipts/great_circle.ipynb
@@ -377,9 +377,7 @@
" assert abs(key[0] - list(astropy_csc2s.keys())[i][0]) < 0.0005\n",
" assert abs(key[1] - list(astropy_csc2s.keys())[i][1]) < 0.0005\n",
" except Exception:\n",
- " if (\n",
- " not math.isclose(abs(key[0]), 90) and not math.isclose(abs(key[1]), 180)\n",
- " ):\n",
+ " if not math.isclose(abs(key[0]), 90) and not math.isclose(abs(key[1]), 180):\n",
" print(abs(key[0] - list(astropy_csc2s.keys())[i][0]))\n",
" print(abs(key[1] - list(astropy_csc2s.keys())[i][1]))\n",
" # Expected places where input lat/lon will not match output lat/lon in NCL\n",