-
Notifications
You must be signed in to change notification settings - Fork 18
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
Clarify role of getAvailableInventoriesandYears
#150
Comments
Correct. This function predates storage of data objects on data commons so does not serve all that much purpose anymore. |
Okay. Thanks for clarifying. I wasn't sure what "available" meant in the
doc string, local or remote. Local is fine. It's a nice summary dictionary.
Any possibility of adding a function parameter or new method to show what's
available remotely (or what data are available for downloading)?
…On Mon, Nov 20, 2023, 22:24 Ben Young (ERG) ***@***.***> wrote:
Are these just the data files that have been downloaded locally and not
the ones available for download?
Correct. This function predates storage of data objects on data commons so
does not serve all that much purpose anymore.
—
Reply to this email directly, view it on GitHub
<#150 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHCFB5LEH4XMHBNNG5DLX53YFQNIXAVCNFSM6AAAAAA7TTP47KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRQGE2TGNBZGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
getAvailableInventoriesandYears
I wrote this to provide the functionality I was talking about above. You just need to update the global dictionary. STEWI_DATA_VINTAGES = {
'DMR': [x for x in range(2011, 2023, 1)],
'GHGRP': [x for x in range(2011, 2023, 1)],
'eGRID': [2014, 2016, 2018, 2019, 2020, 2021],
'NEI': [2011, 2014, 2017, 2020],
'RCRAInfo': [x for x in range(2011, 2023, 2)],
'TRI': [x for x in range(2011, 2023, 1)],
}
'''dict : A dictionary of StEWI inventories and their available vintages.'''
def linear_search(lst, target):
"""Backwards search for the value less than or equal to a given value.
Parameters
----------
lst : list
A list of numerically sorted data (lowest to highest).
target : int, float
A target value (e.g., year).
Returns
-------
int
The index of the search list associated with the value equal to or
less than the target, else -1 for a target out-of-range (i.e., smaller than the smallest entry in the list).
Examples
--------
>>> NEI_YEARS = [2011, 2014, 2017, 2020]
>>> linear_search(NEI_YEARS, 2020)
3
>>> linear_search(NEI_YEARS, 2019)
2
>>> linear_search(NEI_YEARS, 2018)
2
>>> linear_search(NEI_YEARS, 2010)
-1
"""
for i in range(len(lst) - 1, -1, -1):
if lst[i] <= target:
return i
return -1
def get_stewi_invent_years(year):
"""Helper function to return inventory years of interest from StEWI.
See https://github.com/USEPA/standardizedinventories for inventory names
and years.
Parameters
----------
year : int
An inventory vintage (e.g., 2020).
Returns
-------
dict
A dictionary of inventory codes and their most recent year of
data available (less than or equal to the year provided).
Examples
--------
>>> get_stewi_invent_years(2019)
"""
r_dict = {}
for key in STEWI_DATA_VINTAGES.keys():
avail_years = STEWI_DATA_VINTAGES[key]
y_idx = linear_search(avail_years, year)
if y_idx != -1:
r_dict[key] = STEWI_DATA_VINTAGES[key][y_idx]
return r_dict |
@dt-woods it'd be great if you could do a PR of these new functions into develop. my suggestion might be to add |
Will do. Thanks!
…On Fri, Jan 17, 2025, 11:16 Ben Young (ERG) ***@***.***> wrote:
@dt-woods <https://github.com/dt-woods> it'd be great if you could do a
PR of these new functions into develop. my suggestion might be to add
get_stewi_invent_years() to stewi/init.py and linear_search() and
STEWI_DATA_VINTAGES to stewi/globals.py
—
Reply to this email directly, view it on GitHub
<#150 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHCFB5KK2PM4CF6KBOR3QG32LEUF3AVCNFSM6AAAAABUAFYN6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJYG4YDKOJWGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
The table in the README says RCRAInfo has 2013, 2017 and 2019 data available, but I don't see them with I run the following code snippet (using stewi 1.1.2). I only see 2015 data.
Are these just the data files that have been downloaded locally and not the ones available for download?
standardizedinventories/stewi/__init__.py
Line 18 in dbe1c5d
The text was updated successfully, but these errors were encountered: