-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-layers): add split time dim script for soil moisture
- Loading branch information
Showing
3 changed files
with
25 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
BASE_URL="ftp://anon-ftp.ceda.ac.uk/neodc/esacci/soil_moisture/data/daily_files/COMBINED/v04.5" | ||
START_DATE=1978-11-01 | ||
OUTPUT_FODLER=./download/soil | ||
BASE_URL="https://owncloud.tuwien.ac.at/index.php/s/bY8j2kBgZlkqFYC/download?path=%2F&files=ESACCI-SOILMOISTURE-L3S-SSMV-MONTHLY_MEAN-COMBINED-19781101-20191231-fv04.7.nc" | ||
OUTPUT_FODLER=./download/soil_moisture | ||
|
||
mkdir -p $OUTPUT_FODLER | ||
|
||
for i in {0..481} | ||
do | ||
NEXT_YEAR=$(date +%Y -d "$START_DATE + $i month") | ||
NEXT_MONTH=$(date +%Y%m%d -d "$START_DATE + $i month") | ||
FILENAME=$OUTPUT_FODLER/$(date +%Y%m%d -d "$START_DATE + $i month").nc | ||
FTP_URL="$BASE_URL/$NEXT_YEAR/ESACCI-SOILMOISTURE-L3S-SSMV-COMBINED-$NEXT_MONTH"000000-fv04.5.nc | ||
echo $FTP_URL | ||
FILENAME=$OUTPUT_FODLER/sm.nc | ||
curl --silent $BASE_URL > $FILENAME | ||
|
||
curl --silent $FTP_URL > $FILENAME | ||
python ./data/split-time-dim.py --file $FILENAME --variable sm_mean | ||
|
||
python ./data/drop-unused-vars.py --file $FILENAME --variable sm | ||
done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
import xarray as xr | ||
import pandas as pd | ||
from datetime import datetime | ||
from argparse import ArgumentParser | ||
|
||
parser = ArgumentParser() | ||
parser.add_argument("-f", "--file", dest="file") | ||
parser.add_argument("-v", "--variable", dest="variable") | ||
args = parser.parse_args() | ||
|
||
ds = xr.open_dataset(args.file, decode_coords=True, decode_cf=True) | ||
da = ds[args.variable] | ||
|
||
for n in range(len(da.time)): | ||
da_slice = da.isel(time=n) | ||
date = pd.to_datetime(str(da_slice.time.values)) | ||
filename = date.strftime('./download/soil_moisture/%Y%m%d.nc') | ||
print(filename) | ||
da_slice.to_dataset().to_netcdf(filename, format='NETCDF4', mode='w') |