python和matlab读取SST数据(海洋的温度)(.nc文件)并绘图 您所在的位置:网站首页 nc文件处理成同一个经纬度 python和matlab读取SST数据(海洋的温度)(.nc文件)并绘图

python和matlab读取SST数据(海洋的温度)(.nc文件)并绘图

2024-07-10 23:35| 来源: 网络整理| 查看: 265

第一次写博客,请见谅。

参加学校的预赛,做的是2020年美赛A题。解题思路可查“2020年美赛A题总结”,里面有具体的解法。我就不借花谢佛了。下面关于SST数据的读取和绘制虽然繁琐了点,但确实是可成的,之后我将优化他们。

1、SST数据(ERsst.mnmean.nc)来源于北京大学地理数据平台

2、通过matlab读取某一个月的SST数据

我当时下载时,下载下来的数据是从1854年的1月到2018年5月。

在nc文件中,经度 lon从上到下依次为0,2,4,6,8,...,358 纬度lat依次为88,86,84,...,-88 在matlab中,Data(lon,lat,month)索引分别为: lon:1-180;lat:1-89;month:1-1973(根据SST的最终月份决定) Data=ncread('ERsst.mnmean.nc','sst'); %Read temperature data SST g=double(Data(:,:,1958)); h=g(:,89:-1:1);

3、通过python处理数据画图

将数据保存进excel中,从第二行开始粘贴!!!

import matplotlib.pyplot as plt import numpy as np import pandas as pd # Read temperature data (Excel) df = pd.read_excel("data.xlsx") height, width = df.shape print(height, width, type(df)) # The temperature in all coordinates is set to 0 first temperature = np.zeros((180, 89)) # Read temperature data into for i in range(height - 1): for j in range(width - 1): """ If the SST data in a certain latitude and longitude is very small, it means that this place is land. The purpose of converting this temperature to 0 degrees is to simplify the graph. """ if df.iloc[i, j]


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有