-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_finn_data.sh
executable file
·47 lines (36 loc) · 1.4 KB
/
get_finn_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
export LC_NUMERIC="en_US.UTF-8"
#------------------------------------------------
#Input-Data:
start_date="2021-12-01" #"%Y-%m-%d %H"
end_date="2021-12-03" #"%Y-%m-%d %H"
chemistry="GEOSchem" #GEOSchem # MOZ4 # SAPRC99
finn_data_directory="./finn_data/"
#------------------------------------------------
thisYear=$( date +"%Y" )
start_date_s=$(date -d "$start_date" +%s)
end_date_s=$(date -d "$end_date " +%s)
YYYY=$(date -d @$start_date_s +"%Y") #año
DDD=$(date -d @$start_date_s +"%j") #dia juliano
day=$start_date_s
while [ $day -le $end_date_s ]
do
YYYY=$(date -d @$day +"%Y") #año
MM=$(date -d @$day +"%m") #mes
DDD=$(date -d @$day +"%j") #dia juliano
HH=$(date -d @$day +"%H") #hora
echo "Dia: $YYYY-$DDD (mes: $MM)"
#Get FINN data:
if [ ! -f $finn_data_directory/GLOB_${chemistry}_$YYYY$DDD.txt ]
then
if [ $YYYY -le $(($thisYear-2)) ] #los años viejos los tienen en carpetas.
then
wget "https://www.acom.ucar.edu/acresp/MODELING/finn_emis_txt/$YYYY/GLOB_${chemistry}_$YYYY$DDD.txt.gz" -P finn_data/
else
wget "https://www.acom.ucar.edu/acresp/MODELING/finn_emis_txt/GLOB_${chemistry}_$YYYY$DDD.txt.gz" -P finn_data/
fi;
gzip -d finn_data/GLOB_${chemistry}_$YYYY$DDD.txt.gz
fi;
finnFile=finn_data/GLOB_${chemistry}_$YYYY$DDD.txt
day=$(($day + 86400 )) # Incrementar day un dia
done