-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input data overhaul #184
Merged
Merged
Input data overhaul #184
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
d28af3f
moved csv to it's own class
scotthavens 498fb1e
added wrf loading
scotthavens 75f463a
netcdf loading
scotthavens 086c37d
hrrr grib loading
scotthavens d4089b9
some cleanup
scotthavens 739ece2
organized the tests to exapand testing of data
scotthavens df20f44
initial hrrr timestep working with the non threaded run
scotthavens fa91111
loading of hrrr working for non threaded run
scotthavens c249d72
data queue that loads all data for the threads to access
scotthavens a802564
working for now with hrrr loading as a thread
scotthavens df7d460
logging in tests
scotthavens b845bb4
Merge branch '18_threading' into gridded_data
scotthavens 1220ff2
needed the updated threading scheme for the hrrr data
scotthavens 394c3e4
Topo class and some logging leftovers
scotthavens c39f9dc
added a hrrr cloud factor interpolater for a single time step
scotthavens 0390815
flake8 and isort
scotthavens ffd1ca8
order import for data
scotthavens 851a2a7
performing a test on tuolumne and had to make some fixes
scotthavens 23266f0
default clear sky if first is night time
scotthavens 9090a48
added an argument for the create-distributed_threads for awsm
scotthavens c611013
Merge remote-tracking branch 'upstream/master' into gridded_data
scotthavens 750455c
messed up on the merge conflicts
scotthavens 5b185d8
Merge remote-tracking branch 'upstream/master' into gridded_data
scotthavens ed9616c
some last cleanup from the merge
scotthavens f019a48
renamed the data classes, started to consolidate the threads
scotthavens 8c261f6
streamlined the thread creation as all need the smrf and data queues,…
scotthavens 2152cd9
moved initializeDistribution to create_distribution (going to break A…
scotthavens 787c851
cleaned up wrf, all gridded datasets are treated the same
scotthavens b06eb00
Merge remote-tracking branch 'upstream/master' into gridded_data
scotthavens b63d531
updating for new test structure
scotthavens fea4ed5
removed mysql as an input data type, fix #127
scotthavens 73b5f90
flake8 and isort
scotthavens 5aecc16
fixing some import errors after isort
scotthavens 634a42f
addressing review comments
scotthavens a44b65f
flake8
scotthavens 4699dab
data types for functions
scotthavens bdd04a5
one more data type
scotthavens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# flake8: noqa | ||
from . import loadData, loadGrid, loadTopo, mysql_data | ||
from .csv import InputCSV | ||
from .hrrr_grib import InputGribHRRR | ||
from .load_topo import Topo | ||
from .netcdf import InputNetcdf | ||
from .wrf import InputWRF | ||
|
||
from .load_data import InputData # isort:skip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import logging | ||
|
||
import pandas as pd | ||
|
||
from smrf.utils.utils import check_station_colocation | ||
|
||
|
||
class InputCSV(): | ||
|
||
def __init__(self, *args, **kwargs): | ||
|
||
for keys in kwargs.keys(): | ||
setattr(self, keys, kwargs[keys]) | ||
jomey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
self._logger = logging.getLogger(__name__) | ||
jomey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if self.stations is not None: | ||
self._logger.debug('Using only stations {0}'.format( | ||
", ".join(self.stations))) | ||
|
||
def load(self): | ||
""" | ||
Load the data from a csv file | ||
Fields that are operated on | ||
- metadata -> dictionary, one for each station, | ||
must have at least the following: | ||
primary_id, X, Y, elevation | ||
- csv data files -> dictionary, one for each time step, | ||
must have at least the following columns: | ||
date_time, column names matching metadata.primary_id | ||
""" | ||
|
||
self._logger.info('Reading data coming from CSV files') | ||
|
||
variable_list = list(self.config.keys()) | ||
variable_list.remove('stations') | ||
|
||
self._logger.debug('Reading {}...'.format(self.config['metadata'])) | ||
metadata = pd.read_csv( | ||
self.config['metadata'], | ||
index_col='primary_id') | ||
# Ensure all stations are all caps. | ||
metadata.index = [s.upper() for s in metadata.index] | ||
self.metadata = metadata | ||
variable_list.remove('metadata') | ||
|
||
for variable in variable_list: | ||
filename = self.config[variable] | ||
|
||
self._logger.debug('Reading {}...'.format(filename)) | ||
|
||
df = pd.read_csv( | ||
filename, | ||
index_col='date_time', | ||
parse_dates=[0]) | ||
df = df.tz_localize(self.time_zone) | ||
df.columns = [s.upper() for s in df.columns] | ||
|
||
if self.stations is not None: | ||
df = df[df.columns[(df.columns).isin(self.stations)]] | ||
|
||
# Only get the desired dates | ||
df = df[self.start_date:self.end_date] | ||
|
||
if df.empty: | ||
raise Exception("No CSV data found for {0}" | ||
"".format(variable)) | ||
|
||
setattr(self, variable, df) | ||
|
||
def check_colocation(self): | ||
# Check all sections for stations that are colocated | ||
colocated = check_station_colocation(metadata=self.metadata) | ||
if colocated is not None: | ||
self._logger.error( | ||
"Stations are colocated: {}".format(','.join(colocated[0]))) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break AWSM. Should be included in AWSM #68