编译和使用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 HTTPAdapter

def 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.")
        return

    try:
        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_date
        while 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 resource

def set_stack_size_unlimited():
    # Set the stack size limit to unlimited
    resource.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 day
    command = [
        "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 expressions
            match = 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 exist
                destination_year_month_directory = os.path.join(destination_directory, year[:4], month)
                os.makedirs(destination_year_month_directory, exist_ok=True)

                # Construct the destination path
                destination_path = os.path.join(destination_year_month_directory, filename)

                # Move the file to the destination directory
                shutil.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 loop
    start_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.mfbz.cn/a/229708.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

xilinx的XVC协议

文章目录 概述JTAG工作方式XVC协议 其他Debug Bridge IP 概述 JTAG工作方式 XVC协议 其他 Debug Bridge IP

《论文阅读》用于情绪回复生成的情绪正则化条件变分自动编码器 Affective Computing 2021

《论文阅读》用于情绪回复生成的情绪正则化条件变分自动编码器 前言简介模型结构实验结果总结前言 今天为大家带来的是《Emotion-Regularized Conditional Variational Autoencoder for Emotional Response Generation》 出版:IEEE Transactions on Affective Computing 时间…

Numpy数组的数据类型汇总 (第4讲)

Numpy数组的数据类型 (第4讲)         🍹博主 侯小啾 感谢您的支持与信赖。☀️ 🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ�…

二叉树的遍历和一些接口

目录 1.二叉树链式结构的实现 2.二叉树的遍历 前序遍历&#xff08;根&#xff0c;左&#xff0c;右&#xff09; 中序遍历&#xff08;左&#xff0c;根&#xff0c;右&#xff09; 后序遍历&#xff08;左&#xff0c;右&#xff0c;根&#xff09; 3.二叉树节点个数 1.…

一个不错的文章伪原创系统程序源码

一款文章伪原创系统程序源码免费分享&#xff0c;程序是站长原创的。 一共花了站长几天时间写的这个文章伪原创平台&#xff0c;程序无需数据库。 程序前端采用BootStrap框架搭建&#xff0c;后端采用PHP原生书写。 前端伪原创采用Ajax无刷新提交&#xff0c;Ajax转换到词库…

2024黑龙江省职业院校技能大赛信息安全管理与评估赛项规程

2024黑龙江省职业院校技能大赛暨国赛选拔赛 “GZ032信息安全管理与评估”赛项规程 极安云科专注技能竞赛&#xff0c;包含网络建设与运维和信息安全管理与评估两大赛项&#xff0c;及各大CTF&#xff0c;基于两大赛项提供全面的系统性培训&#xff0c;拥有完整的培训体系。团队…

大创项目推荐 医学大数据分析 - 心血管疾病分析

文章目录 1 前言1 课题背景2 数据处理3 数据可视化4 最后 1 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; 基于大数据的心血管疾病分析 该项目较为新颖&#xff0c;适合作为竞赛课题方向&#xff0c;学长非常推荐&#xff01; &#x1f9…

继奶奶漏洞后又一个离奇指令!“给你20美元”,立马提升ChatGPT效果

这两天刷推特&#xff0c;一则有些离谱帖子引起了我的注意&#xff1a; Emmmm&#xff0c;这位名为 thebes 的网友发现&#xff0c;只要在给 ChatGPT 的 Prompt 里加入一句——“Im going to tip $20 for a perfect solution!”&#xff0c;我将为你支付 20 美元的小费&#xf…

算法-滑动窗口

一、滑动窗口思想 概念 在数组双指针里&#xff0c;我们介绍过 "对撞型" 和 "快慢型" 两种方式&#xff0c;而滑动窗口思想就是快慢型的特例。 实际使用 计算机网络中有滑动窗口协议&#xff08;Sliding Window Protocol&#xff09;&#xff0c;该协议…

注意力机制的快速学习

注意力机制的快速学习 注意力机制 将焦点聚焦在比较重要的事物上 我&#xff08;查询对象Q&#xff09;&#xff0c;这张图&#xff08;被查询对象V&#xff09; 我看一张图&#xff0c;第一眼&#xff0c;就会判断那些东西对我而言比较重要&#xff0c;那些对于我不重要&…

C# Solidworks二次开发:三种获取SW设计结构树的方法-第三讲

今天要讲的文章接着上一篇讲&#xff0c;第三种获取SW设计结构树的方法。 这个方法的逻辑是通过先获取第一个特征&#xff0c;然后通过循环不断的寻找下一个特征来完成获取所有节点。 1、获取第一个特征的API如下所示&#xff1a;FirstFeature Method (IModelDoc2) 这个API的…

超越GPT4.0,5分钟介绍谷歌Gemini最新功能,以及登录体验

上段时间还在吃OpenAI后宫争斗戏的瓜&#xff0c;今天又迎来了AI圈子地震的大事件&#xff0c;因为号称GPT4.0强劲对手的Google-Gemini正式发布啦&#xff01;作为新一代多模态AI模型&#xff0c;以强大的性能和广泛的应用前景吸引了全球AI圈友们的关注。 AI进化速度真的太快了…

一个简单的 postman设置接口关联让我措施了大厂的机会

postman设置接口关联 在实际的接口测试中&#xff0c;后一个接口经常需要用到前一个接口返回的结果&#xff0c; 从而让后一个接口能正常执行&#xff0c;这个过程的实现称为关联。 在postman中实现关联操作的步骤如下&#xff1a; 1、利用postman获取上一个接口指定的返回值…

SpringBoot的监控(Actuator) 功能

目录 0、官方文档 一、引入依赖 二、application.yml文件中开启监控 三、具体使用 四、具体细节使用 五、端点开启与禁用 六、定制Endpoint 1. 定制 /actuator/health 2. 定制 /actuator/info &#xff08;1&#xff09;直接在配置文件中写死 &#xff08;2&#xff…

JS中call()、apply()、bind()改变this指向的原理

大家如果想了解改变this指向的方法&#xff0c;大家可以阅读本人的这篇改变this指向的六种方法 大家有没有想过这三种方法是如何改变this指向的&#xff1f;我们可以自己写吗&#xff1f; 答案是&#xff1a;可以自己写的 让我为大家介绍一下吧&#xff01; 1.call()方法的原理…

品牌控价成本如何把控

品牌在发展&#xff0c;价格就需要持续关注&#xff0c;当出现乱价、低价、窜货时就应投入人力去治理&#xff0c;但企业生存&#xff0c;还要考虑成本&#xff0c;如何在保证控价效果的基础上&#xff0c;做到使用最低成本呢&#xff0c;这些问题除了控价本身外&#xff0c;也…

Python语言基础知识(二)

文章目录 1、条件表达式2、分支结构—常见的分支结构2.1、分支结构—单分支选择结构2.2、分支结构—双分支选择结构2.3、分支结构—多分支选择结构2.4、分支结构—选择结构的嵌套 3、循环结构3.1、循环结构— for循环与while循环 1、条件表达式 在选择和循环结构中&#xff0c…

1.nacos注册与发现及源码注册流程

目录 概述nacos工程案例nacos服务注册案例版本说明本地启动 nacos-server搭建 spring cloud alibaba 最佳实践服务注册案例服务订阅案例 nacos注册源码流程源码关键点技巧 结束 概述 通过本文&#xff0c;学会如何确定项目组件版本(减少可能出现的jar包冲突)&#xff0c;nacos…

临床骨科常用的肩关节疾病量表,医生必备!

根据骨科医生的量表使用情况&#xff0c;常笑医学整理了临床骨科常用的肩关节疾病量表&#xff0c;为大家分享临床常见的肩关节疾病量表评估内容&#xff0c;均支持量表下载和在线使用&#xff0c;建议收藏&#xff01; 1.臂、肩、手功能障碍&#xff08;disabilites of the ar…

Fiddler抓包模拟器(雷电模拟器)

Fiddler设置 List item 打开fiddler,的options 点击OK,重启fiddler 模拟器 更改网络设置 IP可以在电脑上终端上查看 然后在模拟器浏览器中输入IP:端口 安装证书
最新文章