編譯和使用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.pswp.cn/news/207474.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/207474.shtml
英文地址,請注明出處:http://en.pswp.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觸發才會…