All CMEMS in situ data products can be found and downloaded after registration via CMEMS catalogue.
Such channel is advisable just for sporadic netCDF donwloading because when operational, interaction with the web user interface is not practical. In this context though, the use of scripts for ftp file transference is is a much more advisable approach.
As long as every line of such files contains information about the netCDFs contained within the different directories see at tips why, it is posible for users to loop over its lines to download only those that matches a number of specifications such as spatial coverage, time coverage, provider, data_mode, parameters or file_name related (region, data type, TS or PF, platform code, or/and platform category, timestamp).
i.e:
In [50]:
user = '' #type CMEMS user name
password = '' #type CMEMS password
product_name = 'INSITU_BAL_NRT_OBSERVATIONS_013_032' #type aimed CMEMS in situ product
distribution_unit = 'cmems.smhi.se' #type aimed hosting institution
In [ ]:
import ftplib
1. index history example (NRT & REP products)
In [51]:
ftp=ftplib.FTP(distribution_unit,user,password)
ftp.cwd("Core")
ftp.cwd(product_name)
aimedFileName = 'index_history.txt'
local_filename = aimedFileName
local_file = open(local_filename, 'wb')
ftp.retrbinary('RETR ' + aimedFileName, local_file.write)
local_file.close()
ftp.quit()
#ready when 221 Goodbye.!
Out[51]:
2. index monthly example (NRT products)
In [34]:
ftp=ftplib.FTP(distribution_unit,user,password)
ftp.cwd("Core")
ftp.cwd(product_name)
aimedFileName = 'index_monthly.txt'
local_filename = aimedFileName
local_file = open(local_filename, 'wb')
ftp.retrbinary('RETR ' + aimedFileName, local_file.write)
local_file.close()
ftp.quit()
#ready when 221 Goodbye.!
Out[34]:
3. index latest example (NRT products)
In [35]:
ftp=ftplib.FTP(distribution_unit,user,password)
ftp.cwd("Core")
ftp.cwd(product_name)
aimedFileName = 'index_latest.txt'
local_filename = aimedFileName
local_file = open(local_filename, 'wb')
ftp.retrbinary('RETR ' + aimedFileName, local_file.write)
local_file.close()
ftp.quit()
#ready when 221 Goodbye.!
Out[35]:
In [52]:
import numpy as np
import pandas as pd
from random import randint
In [53]:
index_file = 'index_history.txt' #choose index file to look at a ramdom line
In [54]:
index = np.genfromtxt(index_file, skip_header=6, unpack=False, delimiter=',', dtype=None,
names=['catalog_id', 'file_name', 'geospatial_lat_min', 'geospatial_lat_max',
'geospatial_lon_min', 'geospatial_lon_max',
'time_coverage_start', 'time_coverage_end',
'provider', 'date_update', 'data_mode', 'parameters'])
In [55]:
dataset = randint(0,len(index)) #ramdom line of the index file
In [56]:
values = [index[dataset]['catalog_id'], '<a href='+index[dataset]['file_name']+'>'+index[dataset]['file_name']+'</a>', index[dataset]['geospatial_lat_min'], index[dataset]['geospatial_lat_max'],
index[dataset]['geospatial_lon_min'], index[dataset]['geospatial_lon_max'], index[dataset]['time_coverage_start'],
index[dataset]['time_coverage_end'], index[dataset]['provider'], index[dataset]['date_update'], index[dataset]['data_mode'],
index[dataset]['parameters']]
headers = ['catalog_id', 'file_name', 'geospatial_lat_min', 'geospatial_lat_max',
'geospatial_lon_min', 'geospatial_lon_max',
'time_coverage_start', 'time_coverage_end',
'provider', 'date_update', 'data_mode', 'parameters']
df = pd.DataFrame(values, index=headers, columns=[dataset])
df.style
Out[56]:
In [ ]: