Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rtd github download #86

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
568 changes: 61 additions & 507 deletions docs/example/plot_basic_statistical_analysis.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/example/plot_formatting_coordinates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.15"
}
},
"nbformat": 4,
Expand Down
439 changes: 58 additions & 381 deletions docs/example/plot_geographic_finite_difference.ipynb

Large diffs are not rendered by default.

110 changes: 109 additions & 1 deletion docs/example/plot_interp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,114 @@
"source": [
"fig, ax = plt.subplots(1, 2, figsize=(12, 5))\n\nu_data.sel(level=500).isel(time=0).plot(ax=ax[0])\nax[0].set_title(\"Before\", size=20)\n\nregriding_data.sel(level=500).isel(time=0).plot(ax=ax[1])\nax[1].set_title(\"After\", size=20)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interpolation from model layers to altitude layers\nSuppose the following data are available\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uwnd_data = xr.DataArray(\n np.array([-15.080393 , -10.749071 , -4.7920494, -2.3813725, -1.4152431,\n -0.6465206, -7.8181705, -14.718096 , -14.65539 , -14.948015 ,\n -13.705519 , -11.443476 , -8.865583 , -7.9528713, -8.329103 ,\n -7.2445316, -6.7150173, -5.5189686, -4.139448 , -3.2731838,\n -2.2931194, -1.0041752, -1.8983078, -2.3674374, -2.8203106,\n -3.2940865, -3.526329 , -3.8654022, -4.164995 , -4.2834396,\n -4.2950516, -4.3438225, -4.3716908, -4.7688255, -4.6155453,\n -4.5528393, -4.4831676, -4.385626 , -4.2950516, -4.0953217]),\n dims = ('model_level',),\n coords = {'model_level': np.array([ 36, 44, 51, 56, 60, 63, 67, 70, 73, 75, 78, 81, 83, 85,\n 88, 90, 92, 94, 96, 98, 100, 102, 104, 105, 107, 109, 111, 113,\n 115, 117, 119, 122, 124, 126, 129, 131, 133, 135, 136, 137])\n }\n)\n\np_data = xr.DataArray(\n np.array([ 2081.4756, 3917.6995, 6162.6455, 8171.3506, 10112.652 ,\n 11811.783 , 14447.391 , 16734.607 , 19317.787 , 21218.21 ,\n 24357.875 , 27871.277 , 30436.492 , 33191.027 , 37698.96 ,\n 40969.438 , 44463.73 , 48191.92 , 52151.29 , 56291.098 ,\n 60525.63 , 64770.367 , 68943.69 , 70979.66 , 74908.17 ,\n 78599.67 , 82012.95 , 85122.69 , 87918.29 , 90401.77 ,\n 92584.94 , 95338.72 , 96862.08 , 98165.305 , 99763.38 ,\n 100626.21 , 101352.69 , 101962.28 , 102228.875 , 102483.055 ]),\n dims = ('model_level',),\n coords = {'model_level': np.array([ 36, 44, 51, 56, 60, 63, 67, 70, 73, 75, 78, 81, 83, 85,\n 88, 90, 92, 94, 96, 98, 100, 102, 104, 105, 107, 109, 111, 113,\n 115, 117, 119, 122, 124, 126, 129, 131, 133, 135, 136, 137])\n }\n)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we interpolate the data located on the mode plane to the isobaric plane. \nNote that the units of the given isobaric surface are consistent with `pressure_data`.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"result = ecl.interp.interp1d_vertical_model2pressure(\n pressure_data = p_data,\n variable_data = uwnd_data,\n vertical_input_dim = 'model_level',\n vertical_output_dim = 'plev',\n vertical_output_level = np.array([100000, 92500, 85000, 70000, 60000, 50000, 40000, 30000, 20000, 10000])\n)\nresult"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Simply calibrate the interpolation effect.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"fig, ax = plt.subplots()\nax.plot(p_data, uwnd_data, label = 'Original')\nax.plot(result.plev, result.data, 'o', label = 'Interpolated')\nax.invert_xaxis()\nax.set_xlabel('Pressure [Pa]')\nax.set_ylabel('Zonal Wind [m/s]')\nplt.legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interpolation from pressure layers to altitude layers\nSuppose the following data are available\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"z_data = xr.DataArray(\n np.array([ 214.19354, 841.6774 , 1516.871 , 3055.7097 , 4260.5806 ,\n 5651.4194 , 7288.032 , 9288.193 , 10501.097 , 11946.71 ,\n 13762.322 , 16233.451 , 18370.902 , 20415.227 , 23619.033 ,\n 26214.322 , 30731.807 ]),\n dims=('level'),\n coords={'level': np.array([1000., 925., 850., 700., 600., 500., 400., 300., 250., 200.,\n 150., 100., 70., 50., 30., 20., 10.])}\n)\nuwnd_data = xr.DataArray(\n np.array([-2.3200073, -3.5700073, -2.5800018, 8.080002 , 14.059998 ,\n 22.119995 , 33.819992 , 49.339996 , 57.86 , 64.009995 ,\n 62.940002 , 49.809998 , 31.160004 , 16.59999 , 10.300003 ,\n 10.459991 , 9.880005 ]),\n dims=('level'), \n coords={'level': np.array([1000., 925., 850., 700., 600., 500., 400., 300., 250., 200.,\n 150., 100., 70., 50., 30., 20., 10.])} \n)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then we need to interpolate the zonal wind data (located on the isobaric surface) to the altitude layers.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"target_heights = np.linspace(0, 10000, 101)\n\nresult = ecl.interp.interp1d_vertical_pressure2altitude(\n z_data = z_data,\n variable_data = uwnd_data,\n target_heights = target_heights,\n vertical_input_dim = 'level',\n vertical_output_dim = 'altitude',\n)\nresult"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can check the interpolation results.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plt.plot(z_data[:9], uwnd_data[:9], 'o', label = 'Original')\nplt.plot(result.altitude, result.data, label = 'Interpolated')\nplt.xlabel('Altitude [m]')\nplt.ylabel('Zonal Wind [m/s]')\nplt.legend()"
]
}
],
"metadata": {
Expand All @@ -161,7 +269,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.15"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/example/plot_taylor_diagram.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.15"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/example/plot_time_scale_average.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.15"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ metpy
tcpypi
netCDF4
h5netcdf
seaborn

sphinx == 8.0.2
recommonmark == 0.7.1
Expand Down
Loading
Loading