-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
250 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
异常时间,异常值,异常数组索引位置 | ||
1997-12-31 17:00:00,9999,8872 | ||
1997-12-31 18:00:00,9999,8873 | ||
1997-12-31 19:00:00,9999,8874 | ||
1997-12-31 20:00:00,9999,8875 | ||
1997-12-31 21:00:00,9999,8876 | ||
1997-12-31 22:00:00,9999,8877 | ||
1997-12-31 23:00:00,9999,8878 | ||
1998-01-01 00:00:00,9999,8879 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# 海洋要素计算 编程作业4\n", | ||
"计算地转流 \n", | ||
"- 1.利用两月的月平均资料计算北太平洋*6°N-35°N*范围内的地转流,选取**1500db**作为参考零面画出*10db*,*100 db*,*250 db*,*500 db*等四个深度层上的流场和流速\n", | ||
"- 2.利用上面计算结果,计算北赤道流水体输运(如130°E,8°N-18°N断面),比较讨论两月结果差异,也可进一步比较不同断面的差异 \n", | ||
" \n", | ||
"**Developed By [Hanxue Yu](https://github.com/Yuhan-xue) 02\\06\\2023** \n", | ||
"**Student ID: 20010006082**" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Import Module" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import netCDF4 as nc\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import pandas as pd\n", | ||
"import gsw" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## NC file Read&Load" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Read" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Key: PRES\n", | ||
" | Long Name: Pressure\n", | ||
" | Units: decibar\n", | ||
" | Shape: (25,)\n", | ||
"Key: TOI\n", | ||
" | Long Name: Temperature.(ITS90)\n", | ||
" | Units: degree_Celsius\n", | ||
" | Shape: (25, 132, 360)\n", | ||
"Key: SOI\n", | ||
" | Long Name: Salinity.(PSS-78)\n", | ||
" | Units: psu\n", | ||
" | Shape: (25, 132, 360)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# NC 文件加载与信息提取\n", | ||
"das1=nc.Dataset('TS_201801_GLB.nc')\n", | ||
"das2=nc.Dataset('TS_201807_GLB.nc')\n", | ||
"def getNCinfo(das):\n", | ||
" for i in list(das.variables.keys()):\n", | ||
" ignolist=['time','lat','lon','LONGITUDE', 'LATITUDE', 'TIME', 'bnds','err','ERR','error','ERROR']\n", | ||
" if i in ignolist or i.split('_')[-1] in ignolist:\n", | ||
" continue\n", | ||
" print(f'Key: {i}')\n", | ||
" print(f' | Long Name: {das.variables[i].long_name}')\n", | ||
" print(f' | Units: {das.variables[i].units}')\n", | ||
" print(f' | Shape: {das.variables[i].shape}')\n", | ||
"getNCinfo(das1)" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Load" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# 变量加载\n", | ||
"## 读取\n", | ||
"DB_01=np.array(das1.variables['PRES'])\n", | ||
"TOI_01=np.array(das1.variables['TOI'])\n", | ||
"SOI_01=np.array(das1.variables['TOI'])\n", | ||
"DB_07=np.array(das2.variables['PRES'])\n", | ||
"TOI_07=np.array(das2.variables['TOI'])\n", | ||
"SOI_07=np.array(das2.variables['TOI'])\n", | ||
"lon=np.array(das1.variables['LONGITUDE'])\n", | ||
"lat=np.array(das1.variables['LATITUDE'])\n", | ||
"## 处理\n", | ||
"lon[lon<0]=lon[lon<0]+360\n", | ||
"SOI_01[SOI_01>1000]=np.nan\n", | ||
"TOI_01[TOI_01>1000]=np.nan\n", | ||
"SOI_07[SOI_07>1000]=np.nan\n", | ||
"TOI_07[TOI_07>1000]=np.nan\n", | ||
"DB_01=np.broadcast_to(DB_01[:,np.newaxis,np.newaxis],SOI_01.shape)\n", | ||
"DB_01=np.broadcast_to(DB_07[:,np.newaxis,np.newaxis],SOI_07.shape)" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Calculate Lattice Distance and Coriolis Parameters" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# 计算格点距离和科氏参数\n", | ||
"def getdx(lon):\n", | ||
" dx=np.zeros(len(lon))\n", | ||
" dx[:-1]=111*(lon[1:]-lon[:-1])\n", | ||
" return np.abs(dx[:-1])\n", | ||
"def getdy(lat):\n", | ||
" dy=np.zeros(len(lat))\n", | ||
" dy[:-1]=111*(lat[1:]-lat[:-1])*np.cos(lat[:-1]*np.pi/180)\n", | ||
" return np.abs(dy[:-1])\n", | ||
"def getCoriolisParm(lat):\n", | ||
" return 2 * 7.29e-5 * np.sin(np.radians(lat))\n", | ||
"dx,dy,f=getdx(lon),getdy(lat),getCoriolisParm(lat)" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Calculates specific volume anomaly\n", | ||
"查询[GSW-Python](https://teos-10.github.io/GSW-Python/gsw_flat.html)文档中gsw.specvol_anom_standard描述与用法\n", | ||
"- 描述\n", | ||
" - Calculates specific volume anomaly from Absolute Salinity, Conservative Temperature and pressure. It uses the computationally-efficient expression for specific volume as a function of SA, CT and p (Roquet et al., 2015). The reference value to which the anomaly is calculated has an Absolute Salinity of SSO and Conservative Temperature equal to 0 degrees C. \n", | ||
"- 输入参数 \n", | ||
" - SA : Absolute Salinity, g/kg \n", | ||
" - CT : Conservative Temperature (ITS-90), degrees C \n", | ||
" - p : Sea pressure (absolute pressure minus 10.1325 dbar), dbar " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# 计算比容异常<使用了GSW-Python模块>\n", | ||
"anomaly = gsw.specvol_anom_standard(SA=SOI_01, CT=TOI_01, p=DB_01)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"RefLevel=1500" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "pynb310", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.10" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Binary file not shown.
Binary file not shown.