get-station-data
A set of Python tools to make it easier to extract weather station data (e.g., temperature, precipitation) from the Global Historical Climatology Network Daily.
https://github.com/scotthosking/get-station-data
Category: Climate Change
Sub Category: Climate Data Access and Visualization
Keywords
python
Keywords from Contributors
cmip6 climate-science
Last synced: about 11 hours ago
JSON representation
Repository metadata
Easily grab weather station data from around the globe (e.g. GHCN)
- Host: GitHub
- URL: https://github.com/scotthosking/get-station-data
- Owner: scotthosking
- License: mit
- Created: 2017-02-28T20:56:10.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2023-10-31T17:29:27.000Z (over 1 year ago)
- Last Synced: 2025-04-10T05:05:07.962Z (18 days ago)
- Topics: python
- Language: Jupyter Notebook
- Homepage:
- Size: 1.03 MB
- Stars: 27
- Watchers: 1
- Forks: 11
- Open Issues: 1
- Releases: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
Get daily weather station data (Global)
A set of Python tools to make it easier to extract weather station data (e.g., temperature, precipitation) from the Global Historical Climatology Network - Daily (GHCND)
"The Global Historical Climatology Network daily (GHCNd) is an integrated database of daily climate summaries from land surface stations across the globe. GHCNd is made up of daily climate records from numerous sources that have been integrated and subjected to a common suite of quality assurance reviews. GHCNd contains records from more than 100,000 stations in 180 countries and territories. NCEI provides numerous daily variables, including maximum and minimum temperature, total daily precipitation, snowfall, and snow depth. About half the stations only report precipitation. Both record length and period of record vary by station and cover intervals ranging from less than a year to more than 175 years." source
More information on the data can be found here
Installation
- Install from the source code:
- Clone the repository source code:
git clone https://github.com/scotthosking/get-station-data.git
- Install along with its dependencies:
cd /path/to/my/get-station-data
pip install -v -e .
Worked through example
from get_station_data import ghcnd
from get_station_data.util import nearest_stn
%matplotlib inline
Read station metadata
stn_md = ghcnd.get_stn_metadata()
Choose a location (lon/lat) and number of nearest neighbours
london_lon_lat = -0.1278, 51.5074
my_stns = nearest_stn(stn_md,
london_lon_lat[0], london_lon_lat[1],
n_neighbours=5 )
my_stns
Download and extract data into a pandas DataFrame
df = ghcnd.get_data(my_stns)
df.head()
Filter data for, e.g., a single variable
var = 'PRCP' # precipitation
df = df[ df['element'] == var ]
### Tidy up columns
df = df.rename(index=str, columns={"value": var})
df = df.drop(['element'], axis=1)
df.head()
df.drop(columns=['mflag','qflag','sflag']).tail(n=10)
Save to file
df.to_csv('London_5stns_GHCN-D.csv', index=False)
Plot histogram of all data
df['PRCP'].plot.hist(bins=40)
<matplotlib.axes._subplots.AxesSubplot at 0x11ae36898>
Plot time series for one station
heathrow = df[ df['name'] == 'HEATHROW' ]
heathrow['PRCP'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x81f0d7240>
Owner metadata
- Name: Scott Hosking
- Login: scotthosking
- Email:
- Kind: user
- Description: Environmental AI, British Antarctic Survey & The Alan Turing Institute
- Website: https://scotthosking.com
- Location: Cambridge, UK
- Twitter: scotthosking
- Company:
- Icon url: https://avatars.githubusercontent.com/u/10783052?u=5dcf6a6816bd735f9e34c322676927228989ac48&v=4
- Repositories: 3
- Last ynced at: 2023-02-28T01:05:19.373Z
- Profile URL: https://github.com/scotthosking
GitHub Events
Total
- Watch event: 2
Last Year
- Watch event: 2
Committers metadata
Last synced: 7 days ago
Total Commits: 97
Total Committers: 7
Avg Commits per committer: 13.857
Development Distribution Score (DDS): 0.33
Commits in past year: 25
Committers in past year: 4
Avg Commits per committer in past year: 6.25
Development Distribution Score (DDS) in past year: 0.44
Name | Commits | |
---|---|---|
Scott Hosking | j****g@g****m | 65 |
Magnus | m****s@g****m | 14 |
Tom Andersson | t****d@b****k | 6 |
Scott Hosking | s****t@S****e | 5 |
Tom Andersson | t****3@g****m | 4 |
Scott Hosking | s****t@S****l | 2 |
Alejandro © | a****c@g****m | 1 |
Committer domains:
- scotts-mbp.home: 1
- bas.ac.uk: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 4
Total pull requests: 6
Average time to close issues: 4 months
Average time to close pull requests: 6 days
Total issue authors: 3
Total pull request authors: 4
Average comments per issue: 3.0
Average comments per pull request: 1.0
Merged pull request: 5
Bot issues: 0
Bot pull requests: 0
Past year issues: 1
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 1
Past year pull request authors: 0
Past year average comments per issue: 0.0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- manmeet3591 (2)
- scotthosking (1)
- magnusross (1)
Top Pull Request Authors
- magnusross (3)
- tom-andersson (1)
- scotthosking (1)
- acocac (1)
Top Issue Labels
Top Pull Request Labels
Score: 5.278114659230517