You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am hoping to use this package to download data. I used the sample py download file. However, whenever I run the example download script I get a Key Error. I am a Windows user and below is my code.
from multiprocessing import freeze_support
import irradpy
import os
from getpass import getpass
class dummy_downloader():
def setUp(self):
# SIMPLE USE CONFIGURATION
## The user should define the input parameters in this script for the easiest use case of the package
# specify your user authentication
self.username = input("Please Enter Your USERNAME: ")
self.password = getpass("Please Enter Your PASSWORD: ")
# specify the date range
self.initial_year = 2018
self.initial_month = 1
self.initial_day = 1
# specify the end date
self.final_year = 2018
self.final_month = 1
self.final_day = 4
# specify the bottom left corner of the rectangular region
self.lat_1 = -90
self.lon_1 = -180
# specify the top left corner of the rectangular region
self.lat_2 = 90
self.lon_2 = 180
# specify the number of threads, this is the number of instances that will run at the same time
# theoretically, this can be as many as you think your machine can handle, though GESDISC may
# impose a limit
self.thread_num = 5
# specify the output destination of the data, depending on operating system changes the file separator
# default location is where you run the script, specify here if you want to change it using os.join.
self.output_dir = 'H:/data/solar_database/ERA5/MERRA2/merra_data' #os.path.join(os.getcwd(),"MERRA2_data")
# specify the merge timelapse of the data
# select from 'none', 'daily', 'monthly', 'yearly'
self.merge_timelapse = 'monthly'
# Here you can change what actually gets downloaded
# full list of variables can be founnd here https://gmao.gsfc.nasa.gov/pubs/docs/Bosilovich785.pdf
self.merra2_var_dicts = {
"rad": {
"esdt_dir": "M2T1NXRAD.5.12.4",
"collection": "tavg1_2d_rad_Nx",
"var_name": ["ALBEDO", "CLDTOT", "SWGDN", "SWGDNCLR", "TAUTOT"],
"standard_name": "radiation",
"least_significant_digit": 3,
},
"slv": {
"esdt_dir": "M2T1NXSLV.5.12.4",
"collection": "tavg1_2d_slv_Nx",
"var_name": ["TQV", "TO3", "PS"],
"standard_name": "surface",
"least_significant_digit": 3,
},
"aer": {
"esdt_dir": "M2T1NXAER.5.12.4",
"collection": "tavg1_2d_aer_Nx",
"var_name": ["TOTSCATAU", "TOTEXTTAU", "TOTANGSTR"],
"standard_name": "aerosols",
"least_significant_digit": 3,
},
}
def download(self):
irradpy.downloader.run(
auth={"uid": self.username, "password": self.password},
initial_year=self.initial_year,
final_year=self.final_year,
initial_month=self.initial_month,
final_month=self.final_month,
initial_day=self.initial_day,
final_day=self.final_day,
lat_1=self.lat_1,
lat_2=self.lat_2,
lon_1=self.lon_1,
lon_2=self.lon_2,
thread_num=self.thread_num,
merra2_var_dicts=self.merra2_var_dicts,
output_dir=self.output_dir,
merge_timelapse=self.merge_timelapse
)
RUN THE DOWNLOADER
if name == "main":
freeze_support()
d = dummy_downloader()
d.setUp()
d.download()
Please Enter Your USERNAME: wenqiqiqiqiqi
Please Enter Your PASSWORD: ········
INFO:root:Downloading data from 2018-1-1 to 2018-1-4...
INFO:root:Request Already Exist in Download Directory, Adding More Files...
KeyError Traceback (most recent call last)
Input In [1], in <cell line: 96>()
98 d = dummy_downloader()
99 d.setUp()
--> 100 d.download()
I am hoping to use this package to download data. I used the sample py download file. However, whenever I run the example download script I get a Key Error. I am a Windows user and below is my code.
from multiprocessing import freeze_support
import irradpy
import os
from getpass import getpass
class dummy_downloader():
def setUp(self):
# SIMPLE USE CONFIGURATION
## The user should define the input parameters in this script for the easiest use case of the package
RUN THE DOWNLOADER
if name == "main":
freeze_support()
d = dummy_downloader()
d.setUp()
d.download()
Please Enter Your USERNAME: wenqiqiqiqiqi
Please Enter Your PASSWORD: ········
INFO:root:Downloading data from 2018-1-1 to 2018-1-4...
INFO:root:Request Already Exist in Download Directory, Adding More Files...
KeyError Traceback (most recent call last)
Input In [1], in <cell line: 96>()
98 d = dummy_downloader()
99 d.setUp()
--> 100 d.download()
Input In [1], in dummy_downloader.download(self)
75 def download(self):
---> 76 irradpy.downloader.run(
77 auth={"uid": self.username, "password": self.password},
78 initial_year=self.initial_year,
79 final_year=self.final_year,
80 initial_month=self.initial_month,
81 final_month=self.final_month,
82 initial_day=self.initial_day,
83 final_day=self.final_day,
84 lat_1=self.lat_1,
85 lat_2=self.lat_2,
86 lon_1=self.lon_1,
87 lon_2=self.lon_2,
88 thread_num=self.thread_num,
89 merra2_var_dicts=self.merra2_var_dicts,
90 output_dir=self.output_dir,
91 merge_timelapse=self.merge_timelapse
92 )
File G:\Anaconda\lib\site-packages\irradpy-1.5.0-py3.9.egg\irradpy\downloader\socket.py:122, in run(collection_names, initial_year, final_year, initial_month, final_month, initial_day, final_day, lat_1, lon_1, lat_2, lon_2, merra2_var_dicts, output_dir, auth, merge_timelapse, thread_num)
120 # Call the main function
121 socket = SocketManager()
--> 122 socket.daily_download_and_convert(
123 collection_names, merra2_var_dicts=merra2_var_dicts,
124 initial_year=initial_year, initial_month=initial_month, initial_day=initial_day,
125 final_year=final_year, final_month=final_month, final_day=final_day,
126 output_dir=output_dir,
127 auth=auth,
128 merge_timelapse=merge_timelapse,
129 lat_1=lat_1, lon_1=lon_1,
130 lat_2=lat_2, lon_2=lon_2,
131 thread_num=thread_num,
132 )
File G:\Anaconda\lib\site-packages\irradpy-1.5.0-py3.9.egg\irradpy\downloader\download.py:645, in SocketManager.daily_download_and_convert(self, collection_names, initial_year, final_year, initial_month, final_month, initial_day, final_day, lat_1, lon_1, lat_2, lon_2, merra2_var_dicts, output_dir, auth, merge_timelapse, merge, thread_num)
643 merra2_var_dict = var_list[collection_name]
644 else:
--> 645 merra2_var_dict = merra2_var_dicts[i]
646 # Download subdaily files
647 # Translate the coordinates that define your area to grid coordinates.
648 lat_coord_1 = self.translate_lat_to_geos5_native(lat_1)
KeyError: 0
The text was updated successfully, but these errors were encountered: