#a new srcipt for silo and backup for the other paper#1 codes
parent
42ab0af07a
commit
d56262cd14
@ -0,0 +1,115 @@
|
|||||||
|
# -*- 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
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
# 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']
|
||||||
|
#==========================================================#
|
||||||
|
|
||||||
|
#==========================================================#
|
||||||
|
#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)
|
||||||
|
mydict = dict((rows[0],[rows[1],rows[2]]) for rows in reader)
|
||||||
|
|
||||||
|
for Estuary in mydict:
|
||||||
|
print Estuary
|
||||||
|
print str(mydict[Estuary][0])
|
||||||
|
|
||||||
|
#==========================================================#
|
||||||
|
#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 +'_' + mydict[Estuary][0] + '_' + mydict[Estuary][1] + '.csv'
|
||||||
|
silo_df = sil.pointdata(Silo_variables, 'Okl9EDxgS2uzjLWtVNIBM5YqwvVcCxOmpd3nCzJh','19900101','20100101',
|
||||||
|
None, mydict[Estuary][0], mydict[Estuary][1], True, output_csv)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue