import numpy as np
import os
import pandas as pd
from bestiapop import bestiapop
#Extend screen
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
In this example we will download climate data based off a list of lat/lon datapoints
We need to define the scope of what type of data and output we expect from BestiaPop.
NOTE: the
coordinate_list
variable contains lists of lat/lon pairs where the first value islatitutde
and the second value islongitude
In this example we retrieved 1724 grids of 5 km resolution from SILO. This lat/lon combinations were masked for the entire potato production areas in Tasmania, Australia. Then we put it in a dataframe and work with the data to create statistical summary and maps of each climate variable.
# Define variables to pass in to Bestiapop
#You need to host your lat/lon list in some web server like GitHub and then provide the url. This example is using a csv hosted in our GitHub repo (sample-data)
from csv import reader
url = "https://raw.githubusercontent.com/JJguri/bestiapop/master/sample-data/bpop_tassie_example.csv" #specify url
df = pd.read_csv(url)
coordinate_list = df.values.tolist()
action='generate-climate-file' #specify action
data_source='nasapower' #specify dta source
year_range='2019-2020' #specify range of years
climate_variables=['radiation', 'max_temp', 'min_temp', 'daily_rain'] #specify climate variables
output_type='dataframe'
output_path=None
#Get MET filed directly in your computer
# #You need to host your lat/lon list in some web server like GitHub and then provide the url. This example is using a csv hosted in our GitHub repo (sample-data)
# from csv import reader
# url = "https://raw.githubusercontent.com/JJguri/bestiapop/master/sample-data/purdue.csv" #specify url
# df = pd.read_csv(url)
# coordinate_list = df.values.tolist()
# action='generate-climate-file' #specify action
# data_source='nasapower' #specify dta source
# year_range='2019-2020' #specify range of years
# climate_variables=['radiation', 'max_temp', 'min_temp', 'daily_rain'] #specify climate variables
# output_type='met'
# output_path=r'C:\Users\uqjojeda\Dropbox\github\ClimateDataAutomation\sample-data'
In this instance we will iterate over the lat/lon combinations
final_df = pd.DataFrame()
for coord in coordinate_list:
print('Fetching data for {}/{}'.format(coord[0], coord[1]))
climate_data = bestiapop.CLIMATEBEAST(
action='generate_met',
data_source=data_source,
output_path=output_path,
output_type=output_type,
input_path=None,
climate_variables=climate_variables,
year_range=year_range,
lat_range=[coord[0]],
lon_range=[coord[1]],
multiprocessing=None
)
data = climate_data.process_records(action)
final_df = final_df.append(data, ignore_index=True)
# Show the final dataframe
final_df
2021-04-12 15:31:49 - POPBEAST - Extracting data and converting to met format 2021-04-12 15:31:49 - POPBEAST.NASAPOWER_CONNECTOR - Generating DataFrames
Fetching data for 40.297382/-86.901067 Total Progress: 0%| | 0/1 [00:00<?, ?it/s]
2021-04-12 15:31:49 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable radiation 2021-04-12 15:31:49 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:31:49 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 40.297382 - Lon -86.901067 for Year 2011 2021-04-12 15:31:49 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:31:49 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:31:52 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:31:52 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 40.297382 - Lon -86.901067 for Year 2012 2021-04-12 15:31:52 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:31:52 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:31:56 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:31:56 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 40.297382 - Lon -86.901067 for Year 2013 2021-04-12 15:31:56 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:31:56 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:31:59 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:31:59 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 40.297382 - Lon -86.901067 for Year 2014 2021-04-12 15:31:59 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:31:59 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:03 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:32:03 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 40.297382 - Lon -86.901067 for Year 2015 2021-04-12 15:32:03 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:03 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:07 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable max_temp 2021-04-12 15:32:07 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:32:07 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 40.297382 - Lon -86.901067 for Year 2011 2021-04-12 15:32:07 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:07 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:10 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:32:10 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 40.297382 - Lon -86.901067 for Year 2012 2021-04-12 15:32:10 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:11 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:14 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:32:14 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 40.297382 - Lon -86.901067 for Year 2013 2021-04-12 15:32:14 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:14 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:19 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:32:19 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 40.297382 - Lon -86.901067 for Year 2014 2021-04-12 15:32:19 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:19 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:23 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:32:23 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 40.297382 - Lon -86.901067 for Year 2015 2021-04-12 15:32:23 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:23 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:27 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable min_temp 2021-04-12 15:32:27 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:32:27 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 40.297382 - Lon -86.901067 for Year 2011 2021-04-12 15:32:27 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:27 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:30 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:32:30 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 40.297382 - Lon -86.901067 for Year 2012 2021-04-12 15:32:30 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:30 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:34 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:32:34 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 40.297382 - Lon -86.901067 for Year 2013 2021-04-12 15:32:34 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:34 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:39 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:32:39 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 40.297382 - Lon -86.901067 for Year 2014 2021-04-12 15:32:39 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:39 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:42 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:32:42 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 40.297382 - Lon -86.901067 for Year 2015 2021-04-12 15:32:42 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:42 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:46 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable daily_rain 2021-04-12 15:32:46 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:32:46 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 40.297382 - Lon -86.901067 for Year 2011 2021-04-12 15:32:46 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:46 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:49 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:32:49 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 40.297382 - Lon -86.901067 for Year 2012 2021-04-12 15:32:49 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:49 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:32:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 40.297382 - Lon -86.901067 for Year 2013 2021-04-12 15:32:55 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:55 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:32:59 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:32:59 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 40.297382 - Lon -86.901067 for Year 2014 2021-04-12 15:32:59 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:32:59 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:02 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:33:02 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 40.297382 - Lon -86.901067 for Year 2015 2021-04-12 15:33:02 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:02 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud
Total Progress: 100%|####################################################################| 1/1 [01:16<00:00, 76.20s/it]
2021-04-12 15:33:06 - POPBEAST - Extracting data and converting to met format 2021-04-12 15:33:06 - POPBEAST.NASAPOWER_CONNECTOR - Generating DataFrames
Fetching data for 39.032738/-85.528156 Total Progress: 0%| | 0/1 [00:00<?, ?it/s]
2021-04-12 15:33:06 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable radiation 2021-04-12 15:33:06 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:33:06 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 39.032738 - Lon -85.528156 for Year 2011 2021-04-12 15:33:06 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:06 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:09 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:33:09 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 39.032738 - Lon -85.528156 for Year 2012 2021-04-12 15:33:09 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:09 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:13 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:33:13 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 39.032738 - Lon -85.528156 for Year 2013 2021-04-12 15:33:13 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:13 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:18 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:33:18 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 39.032738 - Lon -85.528156 for Year 2014 2021-04-12 15:33:18 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:18 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:22 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:33:22 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 39.032738 - Lon -85.528156 for Year 2015 2021-04-12 15:33:22 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:22 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:26 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable max_temp 2021-04-12 15:33:26 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:33:26 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 39.032738 - Lon -85.528156 for Year 2011 2021-04-12 15:33:26 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:26 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:29 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:33:29 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 39.032738 - Lon -85.528156 for Year 2012 2021-04-12 15:33:29 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:29 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:34 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:33:34 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 39.032738 - Lon -85.528156 for Year 2013 2021-04-12 15:33:34 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:34 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:37 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:33:37 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 39.032738 - Lon -85.528156 for Year 2014 2021-04-12 15:33:37 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:37 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:41 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:33:41 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 39.032738 - Lon -85.528156 for Year 2015 2021-04-12 15:33:41 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:41 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:44 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable min_temp 2021-04-12 15:33:44 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:33:44 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 39.032738 - Lon -85.528156 for Year 2011 2021-04-12 15:33:44 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:44 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:48 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:33:48 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 39.032738 - Lon -85.528156 for Year 2012 2021-04-12 15:33:48 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:48 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:51 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:33:51 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 39.032738 - Lon -85.528156 for Year 2013 2021-04-12 15:33:51 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:51 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:33:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 39.032738 - Lon -85.528156 for Year 2014 2021-04-12 15:33:55 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:55 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:33:58 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:33:58 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 39.032738 - Lon -85.528156 for Year 2015 2021-04-12 15:33:58 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:33:58 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:01 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable daily_rain 2021-04-12 15:34:01 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:34:01 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 39.032738 - Lon -85.528156 for Year 2011 2021-04-12 15:34:01 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:01 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:05 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:34:05 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 39.032738 - Lon -85.528156 for Year 2012 2021-04-12 15:34:05 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:05 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:08 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:34:08 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 39.032738 - Lon -85.528156 for Year 2013 2021-04-12 15:34:08 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:08 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:12 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:34:12 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 39.032738 - Lon -85.528156 for Year 2014 2021-04-12 15:34:12 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:12 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:16 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:34:16 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 39.032738 - Lon -85.528156 for Year 2015 2021-04-12 15:34:16 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:16 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud
Total Progress: 100%|####################################################################| 1/1 [01:13<00:00, 73.99s/it]
2021-04-12 15:34:20 - POPBEAST - Extracting data and converting to met format 2021-04-12 15:34:20 - POPBEAST.NASAPOWER_CONNECTOR - Generating DataFrames
Fetching data for 41.105156/-85.397344 Total Progress: 0%| | 0/1 [00:00<?, ?it/s]
2021-04-12 15:34:20 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable radiation 2021-04-12 15:34:20 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:34:20 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 41.105156 - Lon -85.397344 for Year 2011 2021-04-12 15:34:20 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:20 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:23 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:34:23 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 41.105156 - Lon -85.397344 for Year 2012 2021-04-12 15:34:23 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:23 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:27 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:34:27 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 41.105156 - Lon -85.397344 for Year 2013 2021-04-12 15:34:27 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:27 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:30 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:34:30 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 41.105156 - Lon -85.397344 for Year 2014 2021-04-12 15:34:30 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:30 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:34 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:34:34 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable radiation - Lat 41.105156 - Lon -85.397344 for Year 2015 2021-04-12 15:34:34 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:34 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:37 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable max_temp 2021-04-12 15:34:37 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:34:37 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 41.105156 - Lon -85.397344 for Year 2011 2021-04-12 15:34:37 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:37 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:41 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:34:41 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 41.105156 - Lon -85.397344 for Year 2012 2021-04-12 15:34:41 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:41 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:45 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:34:45 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 41.105156 - Lon -85.397344 for Year 2013 2021-04-12 15:34:45 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:45 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:48 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:34:48 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 41.105156 - Lon -85.397344 for Year 2014 2021-04-12 15:34:48 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:48 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:52 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:34:52 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable max_temp - Lat 41.105156 - Lon -85.397344 for Year 2015 2021-04-12 15:34:52 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:52 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable min_temp 2021-04-12 15:34:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:34:55 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 41.105156 - Lon -85.397344 for Year 2011 2021-04-12 15:34:55 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:55 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:34:59 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:34:59 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 41.105156 - Lon -85.397344 for Year 2012 2021-04-12 15:34:59 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:34:59 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:02 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:35:02 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 41.105156 - Lon -85.397344 for Year 2013 2021-04-12 15:35:02 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:02 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:05 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:35:05 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 41.105156 - Lon -85.397344 for Year 2014 2021-04-12 15:35:05 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:05 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:09 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:35:09 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable min_temp - Lat 41.105156 - Lon -85.397344 for Year 2015 2021-04-12 15:35:09 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:09 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:12 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for climate variable daily_rain 2021-04-12 15:35:12 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2011 2021-04-12 15:35:12 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 41.105156 - Lon -85.397344 for Year 2011 2021-04-12 15:35:12 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:12 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:16 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2012 2021-04-12 15:35:16 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 41.105156 - Lon -85.397344 for Year 2012 2021-04-12 15:35:16 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:16 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:19 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2013 2021-04-12 15:35:19 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 41.105156 - Lon -85.397344 for Year 2013 2021-04-12 15:35:19 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:19 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:23 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2014 2021-04-12 15:35:23 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 41.105156 - Lon -85.397344 for Year 2014 2021-04-12 15:35:23 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:23 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud 2021-04-12 15:35:26 - POPBEAST.NASAPOWER_CONNECTOR - Processing data for year 2015 2021-04-12 15:35:26 - POPBEAST.NASAPOWER_CONNECTOR - Processing Variable daily_rain - Lat 41.105156 - Lon -85.397344 for Year 2015 2021-04-12 15:35:26 - POPBEAST.NASAPOWER_CONNECTOR - Extracting data from NASA POWER Climate DataBase 2021-04-12 15:35:26 - POPBEAST.NASAPOWER_CONNECTOR - Need to get data from the NASA Power Cloud
Total Progress: 100%|####################################################################| 1/1 [01:10<00:00, 70.12s/it]
Let's calculate some statistics base on the climate data we retrieved from SILO
NOTE: here we presente the sum of rain and radiation and the mean of daily minimum and maximum temperature across years. You can change the parameters you want to get lookin at the GroupBy documentation.
#calculate yearly mean of mint and maxt (degree C) and cummulative radn (MJ m-2) and rain (mm) during across years and lat/lon combinations
mini = final_df.groupby(['lon','lat','year'], as_index=True)['maxt'].mean().round(decimals=1)
maxi = final_df.groupby(['lon','lat','year'], as_index=True)['mint'].mean().round(decimals=1)
radn = final_df.groupby(['lon','lat','year'], as_index=True)['radn'].sum().round(decimals=1)
rain = final_df.groupby(['lon','lat','year'], as_index=True)['rain'].sum().round(decimals=1)
st0 = pd.merge(radn, mini, on=(['lon','lat','year']), how='outer')
st00 = pd.merge(maxi, rain, on=(['lon','lat','year']), how='outer')
st_final = pd.merge(st0, st00, on=(['lon','lat','year']), how='outer')
st_final
#Save the statistical summary in the current dir
#st_final.to_csv(os.getcwd())
radn | maxt | mint | rain | |||
---|---|---|---|---|---|---|
lon | lat | year | ||||
143.85 | -40.05 | 1991 | 4876.8 | 16.6 | 10.2 | 1020.9 |
1992 | 4663.2 | 16.2 | 10.0 | 1399.2 | ||
1993 | 4901.0 | 16.9 | 10.5 | 922.1 | ||
1994 | 5016.2 | 16.6 | 10.0 | 870.2 | ||
1995 | 4913.9 | 16.3 | 9.5 | 765.7 | ||
... | ... | ... | ... | ... | ... | ... |
148.45 | -40.40 | 2016 | 5105.7 | 18.1 | 11.9 | 961.0 |
2017 | 5356.2 | 17.9 | 11.5 | 633.9 | ||
2018 | 4942.9 | 18.0 | 11.6 | 709.5 | ||
2019 | 5088.6 | 17.9 | 11.2 | 585.0 | ||
2020 | 4664.0 | 17.5 | 11.1 | 741.3 |
51660 rows × 4 columns
#Preparinf dataset to plot
radnrain = final_df.groupby(['lat', 'lon','year'],as_index=True).sum()
temp = final_df.groupby(['lat', 'lon','year'],as_index=True).mean()
#Reseting index
Pre_nc = radnrain.reset_index()
#Set indexes
Pre_nc.set_index(['lat', 'lon', 'year'], inplace=True)
df1 = Pre_nc[~Pre_nc.index.duplicated(keep='first')]
#From 2D dataframe to xarray
nc_r = df1.to_xarray()
#Reseting index
Pre_nc2 = temp.reset_index()
#Set indexes
Pre_nc2.set_index(['lat', 'lon', 'year'], inplace=True)
df2 = Pre_nc2[~Pre_nc2.index.duplicated(keep='first')]
#From 2D dataframe to xarray
nc_t = df2.to_xarray()
NOTE: Each 5 km grid represents the mean (across years) of cumulative rainfall during the year
#Packages required for the mapping functions
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
import matplotlib as mpl
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
#Plotting single map with cumulative rain during the year <--update central longitude in 'projection=ccrs.Mercator(' accordingly with the region of interest
fig, ax = plt.subplots(1, 1, subplot_kw=dict(projection=ccrs.Mercator(central_longitude=146)),figsize=(10,8))
p=nc_r.rain.mean(dim=('year'), skipna=True).plot(x='lon', y='lat', transform=ccrs.PlateCarree(central_longitude=0),
robust=True, cmap=mpl.cm.RdYlBu, zorder=1, add_colorbar=False)
#Arranguing features, borders and axis labels
gl=ax.gridlines(crs=ccrs.PlateCarree(), linewidth=0.01, color='w', alpha=0, linestyle='-', draw_labels=True,dms=True, x_inline=False, y_inline=False)
ax.add_feature(cfeature.COASTLINE, edgecolor = "grey", linewidth=2)
ax.add_feature(cfeature.STATES, edgecolor = "grey", linewidth=0.3, zorder=1)
ax.add_feature(cfeature.OCEAN, color='white', zorder=2)
ax.add_feature(cfeature.LAKES, color='white', zorder=1.5)
ax.add_feature(cfeature.BORDERS, edgecolor = "grey", color='grey', linewidth=1)
#you will need to update the 3 following lines accordingly with the region of interest
ax.set_extent([143.6, 148.8, -43.8, -39.5], crs=ccrs.PlateCarree())
gl.xlocator = mticker.FixedLocator([144, 146, 148])
gl.ylocator = mticker.FixedLocator([-40, -41, -42,-43])
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
gl.xlabel_style = {'size': 17, 'color': 'k'}
gl.ylabel_style = {'size': 17, 'color': 'k'}
ax.outline_patch.set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#Setting colorbar attributes
cb = plt.colorbar(p, orientation="vertical", pad=0.02, shrink=0.9)
cb.set_label(label='Rain (mm)', size='xx-large', weight='bold')
cb.ax.tick_params(labelsize='xx-large')
#Save the map to the current directory
#plt.savefig(os.getcwd(), dpi=600, bbox_inches='tight', pad_inches=0)
NOTE: Each 5 km grid represents the mean (across years) of cumulative solar dariation during the year
#Packages required for the mapping functions
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
import matplotlib as mpl
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
#Plotting single map with cumulative rain during the year <--update central longitude in 'projection=ccrs.Mercator(' accordingly with the region of interest
fig, ax = plt.subplots(1, 1, subplot_kw=dict(projection=ccrs.Mercator(central_longitude=146)),figsize=(10,8))
p=nc_r.radn.mean(dim=('year'), skipna=True).plot(x='lon', y='lat', transform=ccrs.PlateCarree(central_longitude=0),
robust=True, cmap=mpl.cm.YlOrBr_r, zorder=1, add_colorbar=False)
#Arranguing features, borders and axis labels
gl=ax.gridlines(crs=ccrs.PlateCarree(), linewidth=0.01, color='w', alpha=0, linestyle='-', draw_labels=True,dms=True, x_inline=False, y_inline=False)
ax.add_feature(cfeature.COASTLINE, edgecolor = "grey", linewidth=2)
ax.add_feature(cfeature.STATES, edgecolor = "grey", linewidth=0.3, zorder=1)
ax.add_feature(cfeature.OCEAN, color='white', zorder=2)
ax.add_feature(cfeature.LAKES, color='white', zorder=1.5)
ax.add_feature(cfeature.BORDERS, edgecolor = "grey", color='grey', linewidth=1)
#you will need to update the 3 following lines accordingly with the region of interest
ax.set_extent([143.6, 148.8, -43.8, -39.5], crs=ccrs.PlateCarree())
gl.xlocator = mticker.FixedLocator([144, 146, 148])
gl.ylocator = mticker.FixedLocator([-40, -41, -42,-43])
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
gl.xlabel_style = {'size': 17, 'color': 'k'}
gl.ylabel_style = {'size': 17, 'color': 'k'}
ax.outline_patch.set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#Setting colorbar attributes
cb = plt.colorbar(p, orientation="vertical", pad=0.02, shrink=0.9)
cb.set_label(label='Solar Radiation ($MJ\,m^{-2}$)', size='xx-large', weight='bold')
cb.ax.tick_params(labelsize='xx-large')
#Save the map to the current directory
#plt.savefig(os.getcwd(), dpi=600, bbox_inches='tight', pad_inches=0)
NOTE: Each 5 km grid represents the mean (across years) of the mean minimum temperature during the year
#Packages required for the mapping functions
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
import matplotlib as mpl
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
#Plotting single map with cumulative rain during the year <--update central longitude in 'projection=ccrs.Mercator(' accordingly with the region of interest
fig, ax = plt.subplots(1, 1, subplot_kw=dict(projection=ccrs.Mercator(central_longitude=146)),figsize=(10,8))
p=nc_t.mint.mean(dim=('year'), skipna=True).plot(x='lon', y='lat', transform=ccrs.PlateCarree(central_longitude=0),
robust=True, cmap=mpl.cm.RdYlBu_r, zorder=1, add_colorbar=False)
#Arranguing features, borders and axis labels
gl=ax.gridlines(crs=ccrs.PlateCarree(), linewidth=0.01, color='w', alpha=0, linestyle='-', draw_labels=True,dms=True, x_inline=False, y_inline=False)
ax.add_feature(cfeature.COASTLINE, edgecolor = "grey", linewidth=2)
ax.add_feature(cfeature.STATES, edgecolor = "grey", linewidth=0.3, zorder=1)
ax.add_feature(cfeature.OCEAN, color='white', zorder=2)
ax.add_feature(cfeature.LAKES, color='white', zorder=1.5)
ax.add_feature(cfeature.BORDERS, edgecolor = "grey", color='grey', linewidth=1)
#you will need to update the 3 following lines accordingly with the region of interest
ax.set_extent([143.6, 148.8, -43.8, -39.5], crs=ccrs.PlateCarree())
gl.xlocator = mticker.FixedLocator([144, 146, 148])
gl.ylocator = mticker.FixedLocator([-40, -41, -42,-43])
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
gl.xlabel_style = {'size': 17, 'color': 'k'}
gl.ylabel_style = {'size': 17, 'color': 'k'}
ax.outline_patch.set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#Setting colorbar attributes
cb = plt.colorbar(p, orientation="vertical", pad=0.02, shrink=0.9)
cb.set_label(label='Minimum Temperature ($^{\circ}$C)', size='xx-large', weight='bold')
cb.ax.tick_params(labelsize='xx-large')
#Save the map to the current directory
#plt.savefig(os.getcwd(), dpi=600, bbox_inches='tight', pad_inches=0)
NOTE: Each 5 km grid represents the mean (across years) of the mean maximum temperature during the year
#Packages required for the mapping functions
from matplotlib import pyplot as plt
import cartopy.crs as ccrs
import matplotlib as mpl
import cartopy.feature as cfeature
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
#Plotting single map with cumulative rain during the year <--update central longitude in 'projection=ccrs.Mercator(' accordingly with the region of interest
fig, ax = plt.subplots(1, 1, subplot_kw=dict(projection=ccrs.Mercator(central_longitude=146)),figsize=(10,8))
p=nc_t.maxt.mean(dim=('year'), skipna=True).plot(x='lon', y='lat', transform=ccrs.PlateCarree(central_longitude=0),
robust=True, cmap=mpl.cm.RdYlBu_r, zorder=1, add_colorbar=False)
#Arranguing features, borders and axis labels
gl=ax.gridlines(crs=ccrs.PlateCarree(), linewidth=0.01, color='w', alpha=0, linestyle='-', draw_labels=True,dms=True, x_inline=False, y_inline=False)
ax.add_feature(cfeature.COASTLINE, edgecolor = "grey", linewidth=2)
ax.add_feature(cfeature.STATES, edgecolor = "grey", linewidth=0.3, zorder=1)
ax.add_feature(cfeature.OCEAN, color='white', zorder=2)
ax.add_feature(cfeature.LAKES, color='white', zorder=1.5)
ax.add_feature(cfeature.BORDERS, edgecolor = "grey", color='grey', linewidth=1)
#you will need to update the 3 following lines accordingly with the region of interest
ax.set_extent([143.6, 148.8, -43.8, -39.5], crs=ccrs.PlateCarree())
gl.xlocator = mticker.FixedLocator([144, 146, 148])
gl.ylocator = mticker.FixedLocator([-40, -41, -42,-43])
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
gl.xlabel_style = {'size': 17, 'color': 'k'}
gl.ylabel_style = {'size': 17, 'color': 'k'}
ax.outline_patch.set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#Setting colorbar attributes
cb = plt.colorbar(p, orientation="vertical", pad=0.02, shrink=0.9)
cb.set_label(label='Maximum Temperature ($^{\circ}$C)', size='xx-large', weight='bold')
cb.ax.tick_params(labelsize='xx-large')
#Save the map to the current directory
#plt.savefig(os.getcwd(), dpi=600, bbox_inches='tight', pad_inches=0)
Let's now grab all the MET files and maps and compress them. We need to get rid of the ocasional minus sign at the beginning of some
MET files (depending on your lat/lon range), because tar
does not do well with such filenames. In any case, this code should work for you.
NOTE: make sure to change the extension of the file, depending on which format you chose for the output.
%%bash
for f in *.met; do
mv -- "$f" "bpop.${f}"
done
tar chvfz bestiapop_files.tar.gz bpop*
bpop_tassie_example.csv
mv: cannot stat '*.met': No such file or directory
Search for your file by clicking file --> open
in the top left menu of this JupterNotebook. You can download the compressed file and unzip in your own machine (we recommend you use 7zip
if using a Windows machine).