Weather Collection
This file serves to download the weather data collected by the Distributed Scraping Network (DSN)
Attributes:
Name | Type | Description |
---|---|---|
root_path |
str
|
The absolute path to the root of the project directory |
data_path |
string
|
The path to the location of the weather data storage location |
dsn_endpoint |
str
|
The endpoint of the DSN API |
get_error_counts()
The method performs a GET request to the DSN to get the total error count.
The error count represents the number of jobs which failed to collect weather data for a variety of reasons.
Returns:
Type | Description |
---|---|
Json
|
The error count in Json format |
Source code in src/features/dsn_weather_collection.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
retrieve_completed_jobs(start=None, end=None)
Method to perform GET request retrieving the stored weather data at the DSN server.
The start and end parameters provide the index range of the jobs to be returned. For example, specifying start = 0, and end = 1000 will return the first 1000 jobs completed and stored on the DSN
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
int
|
Specification of the start index where collection should start from (included) |
None
|
end |
int
|
Specification of the end index where collection should end (included) |
None
|
Returns:
Type | Description |
---|---|
Json
|
The Json of the request containing all of the requested weather data. If the request fails, None is returned. |
Source code in src/features/dsn_weather_collection.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
retrieve_weather_data(start=None, end=None, file_name='')
Method specifies the process of collection followed by writing the collected data into a single method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
int
|
Specification of the start index where collection should start from (included) |
None
|
end |
int
|
Specification of the end index where collection should end (included) |
None
|
file_name |
str
|
A string specifying the name of the file to write the weather data to (must be a csv file) |
''
|
Source code in src/features/dsn_weather_collection.py
58 59 60 61 62 63 64 65 66 |
|
write_to_csv(data, file)
Method to write the collected weather data to file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Json
|
The weather data collected in Json form |
required |
file |
str
|
The file name where the data should be written to |
required |
Source code in src/features/dsn_weather_collection.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|