编译和使用WPS-ghrsst-to-intermediate生成SST

一、下载

V1.0

https://github.com/bbrashers/WPS-ghrsst-to-intermediate/tree/master

V1.5(使用过程报错,原因不详,能正常使用的麻烦告知一下方法)

https://github.com/dmitryale/WPS-ghrsst-to-intermediate

二、修改makefile

注意:使用什么编译器,那么NETCDF和HDF5也需要使用该编译器编译的版本。
主要修改编译器和NETCDF和HDF5路径

2.1原始文件(PGI)

原始makefile使用PGI编译器编译
在这里插入图片描述

2.2 Gfortran

修改如下

FC      = gfortran
FFLAGS  = -g -std=legacy 
#FFLAGS += -tp=istanbul
FFLAGS += -mcmodel=medium
#FFLAGS += -Kieee                  # use exact IEEE math
#FFLAGS += -Mbounds                # for bounds checking/debugging
#FFLAGS += -Ktrap=fp               # trap floating point exceptions
#FFLAGS += -Bstatic_pgi            # to use static PGI libraries
FFLAGS += -Bstatic                # to use static netCDF libraries
#FFLAGS += -mp=nonuma -nomp        # fix for "can't find libnuma.so"

2.3 Intel

FC      = ifort
FFLAGS  = -g 
FFLAGS += -m64                   # Ensure 64-bit compilation
FFLAGS += -check bounds          # Bounds checking/debugging
# FFLAGS += -fp-model precise    # Use precise floating point model
# FFLAGS += -ftrapuv              # Trap undefined values
FFLAGS += -static-intel          # Use static Intel libraries
# FFLAGS += -Bstatic              # Use static netCDF libraries
FFLAGS += -qopenmp                # Enable OpenMP parallelization

三.编译

make  #生成在自己的路径下
sudo make install  #将生成的ghrsst-to-intermediate复制到/usr/local/bin

四、测试

ghrsst-to-intermediate -h

在这里插入图片描述

五、下载GHRSST数据

使用python进行下载

import os
import requests
from datetime import datetime, timedelta
from urllib.parse import urlparse
import concurrent.futures
import logging
from tqdm import tqdm
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapterdef setup_logging():logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')def download_file_for_date(custom_date, output_folder):url_template = "https://coastwatch.pfeg.noaa.gov/erddap/files/jplMURSST41/{}090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc"url = url_template.format(custom_date)# 创建年/月文件夹year_folder = os.path.join(output_folder, custom_date[:4])month_folder = os.path.join(year_folder, custom_date[4:6])os.makedirs(month_folder, exist_ok=True)parsed_url = urlparse(url)output_file = os.path.join(month_folder, os.path.basename(parsed_url.path))# 检查文件是否已存在,如果存在则跳过下载if os.path.exists(output_file):logging.info(f"File for {custom_date} already exists. Skipping download.")returntry:session = requests.Session()retry = Retry(total=5, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])adapter = HTTPAdapter(max_retries=retry)session.mount('https://', adapter)response = session.get(url, stream=True)response.raise_for_status()  # 检查请求是否成功# 获取文件大小file_size = int(response.headers.get('content-length', 0))# 显示进度条with open(output_file, 'wb') as f, tqdm(desc=f"Downloading {custom_date}", total=file_size,unit="B",unit_scale=True,unit_divisor=1024,dynamic_ncols=True,leave=False) as progress_bar:for data in response.iter_content(chunk_size=1024):f.write(data)progress_bar.update(len(data))logging.info(f"File for {custom_date} downloaded successfully as {output_file}")except requests.exceptions.RequestException as e:logging.error(f"Failed to download file for {custom_date}. {e}")if __name__ == "__main__":setup_logging()# 设置开始和结束日期start_date = datetime(2019, 1, 1)end_date = datetime(2020, 1, 1)# 设置输出文件夹output_folder = ""# 设置线程池大小max_threads = 5# 循环下载文件with concurrent.futures.ThreadPoolExecutor(max_threads) as executor:futures = []current_date = start_datewhile current_date <= end_date:formatted_date = current_date.strftime("%Y%m%d")future = executor.submit(download_file_for_date, formatted_date, output_folder)futures.append(future)current_date += timedelta(days=1)# 等待所有线程完成concurrent.futures.wait(futures)

六、将GHRSST转换为SST文件

import subprocess
from datetime import datetime, timedelta
import os
import shutil
import re
import resourcedef set_stack_size_unlimited():# Set the stack size limit to unlimitedresource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))def process_sst_files(current_date, source_directory):current_day = current_date.strftime("%Y%m%d")year = current_date.strftime("%Y")month = current_date.strftime("%m")# Perform some action for each daycommand = ["ghrsst-to-intermediate","--sst","-g","geo_em.d01.nc",#geo_em.d01.nc文件路径f"{source_directory}/{year}/{month}/{current_day}090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc"]subprocess.run(command)def move_sst_files(source_directory, destination_directory):for filename in os.listdir(source_directory):if filename.startswith("SST"):source_path = os.path.join(source_directory, filename)# Extract year and month from the filename using regular expressionsmatch = re.match(r"SST:(\d{4}-\d{2}-\d{2})_(\d{2})", filename)if match:year, month = match.groups()# Create the destination directory if it doesn't existdestination_year_month_directory = os.path.join(destination_directory, year[:4], month)os.makedirs(destination_year_month_directory, exist_ok=True)# Construct the destination pathdestination_path = os.path.join(destination_year_month_directory, filename)# Move the file to the destination directoryshutil.copyfile(source_path, destination_path)def organize_and_copy_files(SST_path, WPS_path):for root, dirs, files in os.walk(SST_path):for file in files:if 'SST:' in file:origin_file = os.path.join(root, file)for hour in range(1,24,1):#时间间隔调整,跟interval_seconds相同(单位为小时)hour_str = str(hour).rjust(2, '0')copy_file = os.path.join(WPS_path, file.split('_')[0]+'_'+hour_str)if not os.path.exists(copy_file):print(copy_file)shutil.copy(origin_file, copy_file)def main():set_stack_size_unlimited()# Set the start and end dates for the loopstart_date = datetime.strptime("20191231", "%Y%m%d")end_date = datetime.strptime("20200108", "%Y%m%d")source_directory = ""#python代码路径,SST生成在该路径下destination_directory = ""#另存为SST的文件路径WPS_path=""#WPS文件路径#逐一运行ghrsst-to-intermediate,生成当天的SST文件for current_date in (start_date + timedelta(n) for n in range((end_date - start_date).days + 1)):process_sst_files(current_date, source_directory)#将生存的SST文件复制到另外的文件夹中保存move_sst_files(source_directory, destination_directory)#将SST文件按照需要的时间间隔复制organize_and_copy_files(source_directory, WPS_path)if __name__ == "__main__":main()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/207474.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【CVE 复现】CVE-2022-0185 fsconfig之整数溢出

影响版本&#xff1a;Linux-v5.1~v5.16.2 测试版本&#xff1a;Linux-5.11.22&#xff0c;由于懒得搞环境&#xff0c;所以直接用的 bsauce 大佬提供的 测试环境 看看 patch&#xff1a; diff --git a/fs/fs_context.c b/fs/fs_context.c index b7e43a780a625b..24ce12f0db32…

ResNeXt(2017)

文章目录 Abstract1. Introductionformer workour work 2. Related Work多分支卷积网络分组卷积压缩卷积网络Ensembling 3. Method3.1. Template3.2. Revisiting Simple Neurons3.3. Aggregated Transformations3.4. Model Capacity 4. Experiment 原文地址 源代码 Abstract 我…

【python】vscode中选择虚拟环境venv

vscode 怎么指定 python venv&#xff1f; 在VSCode中选择Python解释器&#xff1a; 打开命令面板&#xff1a;按下 CtrlShiftP&#xff08;Windows/Linux&#xff09;或 CmdShiftP&#xff08;Mac&#xff09;。在命令面板中&#xff0c;键入 “Python: Select Interpreter”…

14.Java程序设计-基于Springboot的高校社团管理系统设计与实现

摘要 随着高校社团活动的不断丰富和社团数量的逐渐增加&#xff0c;高校社团管理面临着日益复杂的挑战。为了提高社团管理的效率和透明度&#xff0c;本研究基于Spring Boot框架设计并实现了一套高校社团管理系统。该系统旨在整合社团创建、成员管理、活动发布等多个功能&…

水位线和窗口

水位线特点 插入到数据流中的一个标记&#xff0c;可以认为是一个特殊的数据主要内容是一个时间戳水位线是基于数据的时间戳生成的&#xff0c;即事件时间水位线必须单调递增水位线可以通过设置延迟&#xff0c;来保证正确处理乱序数据一个水位线&#xff0c;表示事件时间已经…

[FPGA 学习记录] 数码管动态显示

数码管动态显示 文章目录 1 理论学习1.1 数码管动态扫描显示原理 2 实战演练2.1 实验目标2.2 程序设计2.2.1 框图绘制2.2.2 数据生成模块 data_gen2.2.2.1 波形绘制2.2.2.2 代码编写2.2.2.3 代码编译2.2.2.4 逻辑仿真2.2.2.4.1 仿真代码编写2.2.2.4.2 仿真代码编译2.2.2.4.3 波…

如何解决el-table中动态添加固定列时出现的行错位

问题描述 在使用el-table组件时&#xff0c;我们有时需要根据用户的操作动态地添加或删除一些固定列&#xff0c;例如操作列或选择列。但是&#xff0c;当我们使用v-if指令来控制固定列的显示或隐藏时&#xff0c;可能会出现表格的行错位的问题&#xff0c;即固定列和非固定列…

el-tree数据量过大,造成浏览器卡死、崩溃

el-tree数据量过大&#xff0c;造成浏览器卡死、崩溃 场景&#xff1a;树形结构展示&#xff0c;数据超级多&#xff0c;超过万条&#xff0c;每次打开都会崩溃 我这里采用的是引入新的插件虚拟树&#xff0c;它是参照element-plus 中TreeV2改造vue2.x版本虚拟化树形控件&…

2024年强烈推荐mac 读写NTFS工具Tuxera NTFS for Mac2023中文破解版

大家好啊&#xff5e;今天要给大家推荐的是 Tuxera NTFS for Mac2023中文破解版&#xff01; 小可爱们肯定知道&#xff0c;Mac系统一直以来都有一个小小的痛点&#xff0c;就是无法直接读写NTFS格式的移动硬盘和U盘。但是&#xff0c;有了Tuxera NTFS for Mac2023&#xff0c;…

正则表达式:字符串处理的瑞士军刀

&#x1f90d; 前端开发工程师&#xff08;主业&#xff09;、技术博主&#xff08;副业&#xff09;、已过CET6 &#x1f368; 阿珊和她的猫_CSDN个人主页 &#x1f560; 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 &#x1f35a; 蓝桥云课签约作者、已在蓝桥云…

记一次xss通杀挖掘历程

前言 前端时间&#xff0c;要开放一个端口&#xff0c;让我进行一次安全检测&#xff0c;发现的一个漏洞。 经过 访问之后发现是类似一个目录索引的端口。(这里上厚码了哈) 错误案例测试 乱输内容asdasffda之后看了一眼Burp的抓包&#xff0c;抓到的内容是可以发现这是一个…

MuJoCo机器人动力学仿真平台安装与教程

MuJoCo是一个机器人动力学仿真平台&#xff0c;它包括一系列的物理引擎、可视化工具和机器人模拟器等工具&#xff0c;用于研究和模拟机器人的运动和动力学特性。以下是MuJoCo的安装教程&#xff1a; 下载和安装MuJoCo Pro。可以从MuJoCo的官方网站上下载最新版本的安装包。根…

【Python机器学习系列】一文彻底搞懂机器学习中表格数据的输入形式(理论+源码)

一、问题 机器学习或者深度学习在处理表格数据&#xff08;Tabular data&#xff09;、图像数据&#xff08;Image data&#xff09;、文本数据&#xff08;Text data&#xff09;、时间序列数据&#xff08;Time series data&#xff09;上得到了广泛的应用。 其中&#xff0c…

微信小程序 - 创建 ZIP 压缩包

微信小程序 - 创建 ZIP 压缩包 场景分享代码片段导入 JSZip创建ZIP文件追加写入文件测试方法参考资料 场景 微信小程序只提供了解压ZIP的API&#xff0c;并没有提供创建ZIP的方法。 当我们想把自己处理好的保存&#xff0c;打包ZIP保存下来时就需要自己实现了。 分享代码片段…

无重复字符的最长子串(LeetCode 3)

文章目录 1.问题描述2.难度等级3.热门指数4.解题思路方法一&#xff1a;暴力法方法二&#xff1a;滑动窗口 参考文献 1.问题描述 给定一个字符串 s &#xff0c;请你找出其中不含有重复字符的最长子串的长度。 s 由英文字母、数字、符号和空格组成。 示例 1&#xff1a; 输…

基于Java商品销售管理系统

基于Java商品销售管理系统 功能需求 1、商品管理&#xff1a;系统需要提供商品信息的管理功能&#xff0c;包括商品的录入、编辑、查询和删除。每个商品应包含基本信息如名称、编码、类别、价格、库存量等。 2、客户管理&#xff1a;系统需要能够记录客户的基本信息&#xf…

算法:常见的哈希表算法

文章目录 两数之和判断是否互为字符重排存在重复元素存在重复元素字母异位词分组 本文总结的是关于哈希表常见的算法 哈希表其实就是一个存储数据的容器&#xff0c;所以其实它本身的算法难度并不高&#xff0c;只是利用哈希表可以对于一些场景进行优化 两数之和 class Solut…

Michael.W基于Foundry精读Openzeppelin第41期——ERC20Capped.sol

Michael.W基于Foundry精读Openzeppelin第41期——ERC20Capped.sol 0. 版本0.1 ERC20Capped.sol 1. 目标合约2. 代码精读2.1 constructor() && cap()2.2 _mint(address account, uint256 amount) 0. 版本 [openzeppelin]&#xff1a;v4.8.3&#xff0c;[forge-std]&…

AI智能降重软件大全,免费最新AI智能降重软件

在当今信息爆炸的时代&#xff0c;内容创作者们面临着巨大的写作压力&#xff0c;如何在保持高质量的前提下提高效率成为摆在许多人面前的难题。AI智能降重软件因其独特的算法和功能逐渐成为提升文案质量的得力助手。本文将专心分享一些优秀的AI智能降重软件。 147SEO改写软件 …

云贝教育 |【技术文章】PostgreSQL中误删除数据怎么办(一)

原文链接&#xff1a;【PostgreSQL】PostgreSQL中误删除数据怎么办&#xff08;一&#xff09; - 课程体系 - 云贝教育 (yunbee.net) 在我们学习完PG的MVCC机制之后&#xff0c;对于DML操作&#xff0c;被操作的行其实并未被删除&#xff0c;只能手工vacuum或自动vacuum触发才会…