# Download OSTIA data from Copernicus Marine Service data store # # Script version: 1.1 # # # #--------------------------------------------- # This script needs "Copernicus Marine Toolbox" # # Install the Toolbox: # # $ conda create --name copernicusmarine conda-forge::copernicusmarine –yes # # Activate the conda environment: # # $ conda activate copernicusmarine # # Check a version: # # $ copernicusmarine –version # # # More information can be found: # https://help.marine.copernicus.eu/en/articles/4469993-how-to-download-copernicus-marine-products # https://help.marine.copernicus.eu/en/articles/7949409-copernicus-marine-toolbox-introduction # https://help.marine.copernicus.eu/en/articles/7970514-copernicus-marine-toolbox-installation # #------------------------------------- # Ver1.0: Created by Mariko Koseki, 05.05.2025 # ver1.1: updated by Mariko, 05.01.2026 ##--- Import modules ---------------------------## import copernicusmarine import sys import glob import os print('Download OSTIA data from Copernicus Marine Service data store') print('') print('------------------') ##--- Input -----------------------------------------## args = sys.argv if len(args) == 2: arg1 = args[1] if arg1 == 'all': print('Download all data') elif len(arg1) == 6: start_year = arg1[0:4] start_month = arg1[4:6] else: print('---How to use this script---') print('python ',args[0],' all') print('or') print('python ',args[0],' ') print('or') print('python ',args[0],' ') print(' = start month; = end month') print('') print('Example: python ',args[0],' all') print('Example: python ',args[0],' 202312') print('Example: python ',args[0],' 199501 202312') print('') sys.exit() elif len(args) == 3: arg1 = args[1] arg2 = args[2] if (len(arg1) == 6) & (len(arg2) == 6): start_year = arg1[0:4] start_month = arg1[4:6] end_year = arg2[0:4] end_month = arg2[4:6] else: print('---How to use this script---') print('python ',args[0],' all') print('or') print('python ',args[0],' ') print('or') print('python ',args[0],' ') print(' = start month; = end month') print('') print('Example: python ',args[0],' all') print('Example: python ',args[0],' 202312') print('Example: python ',args[0],' 199501 202312') print('') sys.exit() else: print('---How to use this script---') print('python ',args[0],' ') print('or') print('python ',args[0],' ') print(' = start month; = end month') print('') print('Example: python ',args[0],' all') print('Example: python ',args[0],' 202312') print('Example: python ',args[0],' 199501 202312') print('') sys.exit() ##--- Set dataset ID ---------------------------## ''' Dataset name: Global Ocean OSTIA Sea Surface Temperature and Sea Ice Reprocessed Product ID: SST_GLO_SST_L4_REP_OBSERVATIONS_010_011 Dataset ID: METOFFICE-GLO-SST-L4-REP-OBS-SST Spatial resolution: 0.05° × 0.05° Period: 1 Oct 1981 to 31 May 2022 Dataset name: Global Ocean OSTIA Sea Surface Temperature and Sea Ice Analysis Product ID: SST_GLO_SST_L4_NRT_OBSERVATIONS_010_001 Dataset ID: METOFFICE-GLO-SST-L4-NRT-OBS-SST-V2 Spatial resolution: 0.05° × 0.05° Period: 1 Jan 2007 to present ''' dataset = 'nrt' #dataset = 'rep' if dataset == 'rep': datasetID = 'METOFFICE-GLO-SST-L4-REP-OBS-SST' data_path = 'SST_GLO_SST_L4_REP_OBSERVATIONS_010_011/METOFFICE-GLO-SST-L4-REP-OBS-SST_202003/' elif dataset == 'nrt': datasetID = 'METOFFICE-GLO-SST-L4-NRT-OBS-SST-V2' data_path = 'SST_GLO_SST_L4_NRT_OBSERVATIONS_010_001/METOFFICE-GLO-SST-L4-NRT-OBS-SST-V2/' print('ID: ',datasetID) print('') ##--- Set date range ----------------------------## #date_range = "*/2021/06/*_2021062[0-3]*.nc" # Define output storage parameters output_directory = '/nird/datapeak/NS9039K/data/external/observation/OSTIA/original/' #ver1.1 ##--- Verify their Copernicus Marine credentials and create the configuration file ---## copernicusmarine.login() ##--- Download the original files ----------------## if arg1 == 'all': print('') print('Download all data') print('') #copernicusmarine.get( #dataset_id=datasetID, #output_directory=output_directory, #) else: if len(args) == 2: print('') print('Download data') print(' start:', start_year, start_month) print('') ### delete existing files ### print('step1: delete existing files') for files in glob.glob(output_directory + data_path + start_year + '/' + start_month + '/' + start_year + start_month + '*', recursive=True): print('file name: ', files) #print('step1') if os.path.isfile(files): #print('files', files) os.remove(files) print('') print('step 2: download OSTIA data') print('') fil='*' + start_year + '/' + start_month + '/*' copernicusmarine.get( dataset_id=datasetID, output_directory=output_directory, filter=fil ) elif len(args) == 3: print('') print('Download data') print(' start:', start_year, start_month) print(' end:', end_year, end_month) print('!---------!') print('Sorry! This function is not available yet!') sys.exit() print('') #copernicusmarine.get( #dataset_id=datasetID, #output_directory=output_directory, #filter="*2025/01/*" #) else: print('') print('no data') sys.exit() print('Download completed!!')