#!/bin/csh

set working = /storage/bluesky/output_archive/hysplit-pp
set YY      = 2018
set MM      = 03

foreach DD ( 01 02 03 04 05 06 07 08 09 10 11 12 13 )
 foreach HH ( 00 12 )
              
  set ymdh = $YY$MM$DD$HH

  foreach model ( CANSAC-6km CANSAC-2km )

    echo === $model $ymdh   `date`

    set workingfull = $working/$model/$ymdh/forecast

    if ( -e $workingfull ) then

      echo $workingfull exists 

      rm -Rf $workingfull/images
      rm -Rf $workingfull/graphics

      /usr/local/bin/makedispersionkml \
              -o $workingfull \
              -O DispersionImages.REPROJECT_IMAGES=TRUE  \
              -l $workingfull/data/fire_locations.csv \
              -e $workingfull/data/fire_events.csv \
              -i $workingfull/data/smoke_dispersion.nc > /dev/null

      mv $workingfull/graphics $workingfull/images

      /home/bluesky/clear-websky-cache standard $model $ymdh
      echo standard/$model/$ymdh cache cleared

    endif

  end
 end
end
