#!/bin/bash

#################################################################################
# Script creado para copiar teselas del WRF al directorio con teselas GFS.
#
# Marcos Molina Cano - 23/11/2016
#################################################################################

# Tipo de mapa.
mapa="prcnub"

# Directorios base de las teselas GFS y WRF.
BASEDIRGFS="/media/marcos/SSD/tiles_GFS/${mapa}"
BASEDIRWRF="/media/marcos/SSD/tiles_WRF/${mapa}"

# Zoom a usar.
z=6

##### Copiado de teselas #####
# AMN013
dominio="amn013"
for ((x=8; x<=23; x++)); do
  for ((y=18; y<=29; y++)); do
    if ((${x} == 22)) ; then
      if ((${y} >= 29)) ; then
        continue
      fi
    fi
    if ((${x} == 23)) ; then
      if ((${y} >= 28)) ; then
        continue
      fi
    fi
    cp ${BASEDIRWRF}/${dominio}/${z}/${x}/${y}.png ${BASEDIRGFS}/${z}/${x}/
  done
done

# AMS013
dominio="ams013"
for ((x=16; x<=25; x++)); do
  for ((y=30; y<=43; y++)); do
    if ((${x} == 16)) ; then
      if ((${y} <= 35)) ; then
        continue
      fi
    fi
    if ((${x} == 17)) ; then
      if ((${y} <= 32)) ; then
        continue
      fi
    fi
      cp ${BASEDIRWRF}/${dominio}/${z}/${x}/${y}.png ${BASEDIRGFS}/${z}/${x}/
  done
done

# AZO010
cp ${BASEDIRWRF}/${dominio}/${z}/26/24.png ${BASEDIRGFS}/${z}/26/

# RUS015
dominio="rus015"
for ((x=37; x<=42; x++)); do
  for ((y=16; y<=22; y++)); do
    cp ${BASEDIRWRF}/${dominio}/${z}/${x}/${y}.png ${BASEDIRGFS}/${z}/${x}/
  done
done

# EUR010
dominio="eur010"
for ((x=29; x<=35; x++)); do
  for ((y=18; y<=25; y++)); do
    cp ${BASEDIRWRF}/${dominio}/${z}/${x}/${y}.png ${BASEDIRGFS}/${z}/${x}/
  done
done
cp ${BASEDIRWRF}/${dominio}/${z}/29/26.png ${BASEDIRGFS}/${z}/29/
cp ${BASEDIRWRF}/${dominio}/${z}/35/26.png ${BASEDIRGFS}/${z}/35/

# MAG016
dominio="mag016"
for ((x=31; x<=33; x++)); do
  for ((y=26; y<=27; y++)); do
    cp ${BASEDIRWRF}/${dominio}/${z}/${x}/${y}.png ${BASEDIRGFS}/${z}/${x}/
  done
done


