Skip to content

Commit

Permalink
06_02_2023
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuhan-xue committed Jun 2, 2023
1 parent 774160c commit 6937bc7
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 5 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@

- 此仓库为中国海洋大学课程:海洋要素计算*(选课号:[070103101251])*的作业而建立
- 所有者:Hanxue Yu 余汉学
- 指导教师:王颖颖
- 指导教师:王颖颖&杨俊超
- 参考:
- Github上可以找到的学长多年前写的[代码仓库](https://github.com/FinalTheory/oceanography-numerical-calculations)
- 海洋要素数据的质量控制中的格林布斯准则参考:[c-bata/outlier-utils](https://github.com/c-bata/outlier-utils)
- 刘永玲.杜凌.李静凯.翟方国 海洋要素计算上机实验指导书[M] 青岛:中国海洋大学出版社,2021
- GB/T 14914.6-2021, 海洋观测规范 第6部分:数据处理与质量控制[S].
- 待续.....
- [GSW-Python](https://teos-10.github.io/GSW-Python/gsw_flat.html)

## 2021/3/14 [海洋要素数据的质量控制](https://nbviewer.org/github/Yuhan-xue/HAN_Marine_element/blob/main/WORK1/WORK1.ipynb)

## 作业一 [海洋要素数据的质量控制](https://nbviewer.org/github/Yuhan-xue/HAN_Marine_element/blob/main/WORK1/WORK1.ipynb)
- 1.**奇异值判定与处理,生成新序列**
- 2.**分析两序列的平均值、标准差等统计特征的变化**
- 拓展作业见[拓展作业-空间二位插值](https://nbviewer.org/github/Yuhan-xue/HAN_Marine_element/blob/main/WORK1/%E6%8B%93%E5%B1%95/%E6%8B%93%E5%B1%951.ipynb)

## 作业二 [利用EOF方法研究北太平洋海表面温度总体时空变化特征](https://nbviewer.org/github/Yuhan-xue/HAN_Marine_element/blob/main/WORK2/work2.ipynb)

## 作业三 [长期水位资料的调和分析](https://nbviewer.org/github/Yuhan-xue/HAN_Marine_element/blob/main/WORK3/WORK3.ipynb)

## 作业四 [地转流计算-施工ing](https://nbviewer.org/github/Yuhan-xue/HAN_Marine_element/blob/main/WORK3/WORK4.ipynb)
Binary file not shown.
20 changes: 18 additions & 2 deletions WORK3/WORK3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,22 @@
"id": "ef44814c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n",
"1997-06-29 20:00:00\n"
]
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -550,7 +566,7 @@
" τ_0=T_0-s_0+h_0\n",
" V_0=np.array([τ_0,s_0,h_0,p_0,N_0,p_dot_0])\n",
" #print(N_0)\n",
" #print(Middle_time)\n",
" print(Middle_time)\n",
" #print(N_0)\n",
" return [get_sigma_V(name,σ,V_0,t)[0],get_sigma_V(name,σ,V_0,t)[1],get_f(name,N_0),get_u(name,N_0)]\n",
"# get4('M2')\n",
Expand Down Expand Up @@ -1017,7 +1033,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "2c11bf8e",
"metadata": {},
"outputs": [
Expand Down
9 changes: 9 additions & 0 deletions WORK3/demo.csv
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 added WORK3/作业三·余汉学20010006082.pdf
Binary file not shown.
Binary file added WORK4/TS_201801_GLB.nc
Binary file not shown.
Binary file added WORK4/TS_201807_GLB.nc
Binary file not shown.
213 changes: 213 additions & 0 deletions WORK4/WORK4.ipynb
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 added WORK4/编程作业4.pdf
Binary file not shown.
Binary file added WORK4/编程作业4.pptx
Binary file not shown.

0 comments on commit 6937bc7

Please sign in to comment.