Skip to content

Commit

Permalink
Merge branch 'ubsuny:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmos491 authored Nov 9, 2024
2 parents dc24f73 + d69824e commit 57b1b42
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
57 changes: 57 additions & 0 deletions methane-data-collection/data/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## This contains the license, citation, and location for each data set used in this module.

### The methane data was sourced from gml.noaa.gov:
These data were produced by NOAA and are not subject to copyright
protection in the United States. NOAA waives any potential copyright and
related rights in these data worldwide through the Creative Commons Zero
1.0 Universal Public Domain Dedication (CC0 1.0)

### CC0 1.0 Universal

The data citation for each set is:

Lan, X., J.W. Mund, A.M. Crotwell, K.W. Thoning, E. Moglia, M. Madronich, K. Baugh,
G. Petron, M.J. Crotwell, D. Neff, S. Wolter, T. Mefford and S. DeVogel (2024),
Atmospheric Carbon Dioxide Dry Air Mole Fractions from the NOAA GML Carbon Cycle Cooperative
Global Air Sampling Network, 1968-2023, Version: 2024-07-30, https://doi.org/10.15138/wkgj-f215

### South America Data:

site_code : USH
site_name : Ushuaia
site_country : Argentina

### Oceania Data:

site_code : CGO
site_name : Cape Grim, Tasmania
site_country : Australia

### North America Data:

site_code : UTA
site_name : Wendover, Utah
site_country : United States

### Africa Data:

site_code : ASK
site_name : Assekrem
site_country : Algeria

### Asia Data:

site_code : AMY
site_name : Anmyeon-do
site_country : Republic of Korea

### Antarctica Data:

site_code : PSA
site_name : Palmer Station, Antarctica
site_country : United States

### Europe Data:
site_code : ZEP
site_name : Ny-Alesund, Svalbard
site_country : Norway and Sweden
15 changes: 10 additions & 5 deletions preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def fft_mag(data):
matrix in half or take the absolut values of the variables"""
n = len(data)
timestamp_sum = sum(data.index[i+1].timestamp() - data.index[i].timestamp() for i in range(n-1))
if not timestamp_sum/(n-1) == data.index[2].timestamp() - data.index[1].timestamp():
compare = np.isclose(timestamp_sum/(n-1),
data.index[2].timestamp() - data.index[1].timestamp(), atol=1e-6)
if not compare:
print("Data is not evenly spaced or data points are missing")
return None
return np.fft.fft(data.values)
Expand Down Expand Up @@ -57,7 +59,7 @@ def calc_freq(data, tim):
diftim = diftim/(60*60*24*30.4375)
return np.fft.fftfreq(n, d = diftim)

def get_timeseries(path):
def get_timeseries(path, datecolumn = 'date', datacolumn = 'CO2 (ppm)'):
'''
This function reads json files from the data collection task
and returns a pandas time series with datetime as index and
Expand All @@ -74,6 +76,7 @@ def get_timeseries(path):
Parameters:
- path: Stringlike. path/to/json/file.json
- datecolumn: to specifiy specific date column name
Returns:
- Pandas Time Series. Index = Datetime, Data = CO2/Methane Concentration
Expand All @@ -84,13 +87,15 @@ def get_timeseries(path):
#Uses the month and year information from the json file,
# assumes data was taken on the first of each month,
# creates new column with datetime
data['date'] = pd.to_datetime(data[['Year', 'Month']].assign(Day=1))

if datecolumn == "date":
data['date'] = pd.to_datetime(data[['Year', 'Month']].assign(Day=1))

#Sets datetime as index
data.set_index('date', inplace=True)
data.set_index(datecolumn, inplace=True)

#Creates timeseries with co2 (ppm) as data and datetime as index
co2_series = data['CO2 (ppm)']
co2_series = data[datacolumn]


return co2_series

0 comments on commit 57b1b42

Please sign in to comment.