From d01486c3283c6ca078029b7204316781dd31d620 Mon Sep 17 00:00:00 2001 From: Meg Fowler Date: Wed, 11 Dec 2024 16:12:48 -0700 Subject: [PATCH 1/2] Add scatter plot for quick comparison --- ...strialCouplingIndex_VisualCompareObs.ipynb | 72 ++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb b/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb index 8ae658e..dc02a5d 100755 --- a/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb +++ b/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb @@ -17,7 +17,7 @@ "- Note: Built to use monthly output; ideally, CI should be based on daily data. \n", "- Optional: Comparison against FLUXNET obs\n", "

\n", - "Notebook created by mdfowler@ucar.edu; Last update: 2 Aug 2024 " + "Notebook created by mdfowler@ucar.edu; Last update: 11 Dec 2024 " ] }, { @@ -923,6 +923,68 @@ " return" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "6003435f-f16d-4c8b-80da-40f9cb571560", + "metadata": {}, + "outputs": [], + "source": [ + "def plotScatter(seasonstr, caseSel = None): \n", + " node_lats = uxgrid.face_lat.values\n", + " node_lons = uxgrid.face_lon.values\n", + "\n", + " predictions = []\n", + " \n", + " fig,axs = plt.subplots(1,1,figsize=(8,8))\n", + " \n", + " \n", + " CI_model = (\n", + " couplingIndex_DS[\"CouplingIndex\"]\n", + " .sel(season=seasonstr)\n", + " )\n", + " \n", + " iSeason = np.where(seasons == seasonstr)[0]\n", + " iStations = np.where(np.isfinite(terraCI_fluxnetConverted[:, iSeason]) == True)[0]\n", + " \n", + " for iPoint in range(len(iStations)):\n", + " this_lon = lon_fluxnet[iStations[iPoint]] # lon1\n", + " this_lat = lat_fluxnet[iStations[iPoint]] # lat1\n", + " obs_point = np.array((this_lon, this_lat))\n", + " \n", + " # Get subset of relevant points \n", + " i = np.where( (node_lats>=(this_lat-2)) & (node_lats<=(this_lat+2)) & \n", + " (node_lons>=(this_lon-2)) & (node_lons<=(this_lon+2)))[0]\n", + " \n", + " minDistance = 100\n", + " for iSelClose in range(len(i)): \n", + " # Find point in uxarray? Use euclidian distance \n", + " distance = np.linalg.norm(obs_point - np.array((node_lons[i[iSelClose]], node_lats[i[iSelClose]])) )\n", + " \n", + " if ( (distance Date: Wed, 11 Dec 2024 16:15:38 -0700 Subject: [PATCH 2/2] Update land TCI notebook to add scatter and fix formatting. --- ...strialCouplingIndex_VisualCompareObs.ipynb | 99 +++++++++++-------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb b/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb index dc02a5d..a505626 100755 --- a/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb +++ b/nblibrary/lnd/Global_TerrestrialCouplingIndex_VisualCompareObs.ipynb @@ -930,58 +930,77 @@ "metadata": {}, "outputs": [], "source": [ - "def plotScatter(seasonstr, caseSel = None): \n", + "def plotScatter(seasonstr, caseSel=None):\n", " node_lats = uxgrid.face_lat.values\n", " node_lons = uxgrid.face_lon.values\n", "\n", " predictions = []\n", - " \n", - " fig,axs = plt.subplots(1,1,figsize=(8,8))\n", - " \n", - " \n", - " CI_model = (\n", - " couplingIndex_DS[\"CouplingIndex\"]\n", - " .sel(season=seasonstr)\n", - " )\n", - " \n", - " iSeason = np.where(seasons == seasonstr)[0]\n", + "\n", + " fig, axs = plt.subplots(1, 1, figsize=(8, 8))\n", + "\n", + " CI_model = couplingIndex_DS[\"CouplingIndex\"].sel(season=seasonstr)\n", + "\n", + " iSeason = np.where(seasons == seasonstr)[0]\n", " iStations = np.where(np.isfinite(terraCI_fluxnetConverted[:, iSeason]) == True)[0]\n", - " \n", + "\n", " for iPoint in range(len(iStations)):\n", " this_lon = lon_fluxnet[iStations[iPoint]] # lon1\n", " this_lat = lat_fluxnet[iStations[iPoint]] # lat1\n", " obs_point = np.array((this_lon, this_lat))\n", - " \n", - " # Get subset of relevant points \n", - " i = np.where( (node_lats>=(this_lat-2)) & (node_lats<=(this_lat+2)) & \n", - " (node_lons>=(this_lon-2)) & (node_lons<=(this_lon+2)))[0]\n", - " \n", + "\n", + " # Get subset of relevant points\n", + " i = np.where(\n", + " (node_lats >= (this_lat - 2))\n", + " & (node_lats <= (this_lat + 2))\n", + " & (node_lons >= (this_lon - 2))\n", + " & (node_lons <= (this_lon + 2))\n", + " )[0]\n", + "\n", " minDistance = 100\n", - " for iSelClose in range(len(i)): \n", - " # Find point in uxarray? Use euclidian distance \n", - " distance = np.linalg.norm(obs_point - np.array((node_lons[i[iSelClose]], node_lats[i[iSelClose]])) )\n", - " \n", - " if ( (distance