|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Created on Wed Jun 20 18:03:25 2018
|
|
|
|
|
|
|
|
@author: z5025317
|
|
|
|
"""
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
#Load packages
|
|
|
|
#==========================================================#
|
|
|
|
import numpy as np
|
|
|
|
import os
|
|
|
|
import pandas as pd
|
|
|
|
import glob
|
|
|
|
import matplotlib
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
from datetime import datetime
|
|
|
|
from datetime import timedelta
|
|
|
|
from matplotlib.backends.backend_pdf import PdfPages
|
|
|
|
from ggplot import *
|
|
|
|
matplotlib.style.use('ggplot')
|
|
|
|
import csv
|
|
|
|
# import own modules
|
|
|
|
# Set working direcotry (where postprocessed NARClIM data is located)
|
|
|
|
os.chdir('C:/Users/z5025317/OneDrive - UNSW/WRL_Postdoc_Manual_Backup/WRL_Postdoc/Projects/Paper#1/Analysis/Code')
|
|
|
|
#import climdata_fcts as fct
|
|
|
|
import silo as sil
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
# Set working direcotry (where postprocessed NARClIM data is located)
|
|
|
|
os.chdir('C:/Users/z5025317/OneDrive - UNSW/WRL_Postdoc_Manual_Backup/WRL_Postdoc/Projects/Paper#1/')
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
#set input parameters
|
|
|
|
Case_Study_Name = 'CASESTUDY2'
|
|
|
|
Casestudy2_csv_path = "Data/NARCLIM_Site_CSVs/CASESTUDY2/CASESTDUY2_NARCLIM_Point_Sites.csv"
|
|
|
|
Silo_variables = ['daily_rain', "max_temp", "min_temp", 'et_short_crop', 'evap_syn']
|
|
|
|
Location = 'Estuary' #'Catchment'
|
|
|
|
startdate= '19600101'
|
|
|
|
enddate= '20180101'
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
#set directory path for output files
|
|
|
|
output_directory = 'Data/SILO/' + Case_Study_Name + '/'
|
|
|
|
#output_directory = 'J:/Project wrl2016032/NARCLIM_Raw_Data/Extracted'
|
|
|
|
if not os.path.exists(output_directory):
|
|
|
|
os.makedirs(output_directory)
|
|
|
|
print('-------------------------------------------')
|
|
|
|
print("output directory folder didn't exist and was generated")
|
|
|
|
print('-------------------------------------------')
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
#read the CSV to extract the lat long and case stuy sites
|
|
|
|
with open(Casestudy2_csv_path, mode='r') as infile:
|
|
|
|
reader = csv.reader(infile)
|
|
|
|
next(reader, None)
|
|
|
|
with open('coors_new.csv', mode='w') as outfile:
|
|
|
|
writer = csv.writer(outfile)
|
|
|
|
if Location == 'Estuary':
|
|
|
|
mydict = dict((rows[0],[rows[1],rows[2]]) for rows in reader)
|
|
|
|
if Location == 'Ocean':
|
|
|
|
mydict = dict((rows[0],[rows[3],rows[4]]) for rows in reader)
|
|
|
|
if Location == 'Catchment':
|
|
|
|
mydict = dict((rows[0],[rows[5],rows[6]]) for rows in reader)
|
|
|
|
|
|
|
|
for Estuary in mydict:
|
|
|
|
print Estuary, mydict[Estuary][0], mydict[Estuary][1]
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
#set directory path for output files
|
|
|
|
output_directory_internal = output_directory + Estuary + '/'
|
|
|
|
#output_directory = 'J:/Project wrl2016032/NARCLIM_Raw_Data/Extracted'
|
|
|
|
if not os.path.exists(output_directory_internal):
|
|
|
|
os.makedirs(output_directory_internal)
|
|
|
|
print('-------------------------------------------')
|
|
|
|
print("output directory folder didn't exist and was generated")
|
|
|
|
print('-------------------------------------------')
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
output_csv = output_directory_internal + 'SILO_climdata_' + Estuary +'_'+ Location +'_' + mydict[Estuary][0] + '_' + mydict[Estuary][1] + '.csv'
|
|
|
|
silo_df = sil.pointdata(Silo_variables, 'Okl9EDxgS2uzjLWtVNIBM5YqwvVcCxOmpd3nCzJh',startdate, enddate,
|
|
|
|
None, mydict[Estuary][0], mydict[Estuary][1], True, output_csv)
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|