Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""Mauna Loa Weekly Atmospheric CO2 Data""" 

2import pandas as pd 

3 

4from statsmodels.datasets import utils as du 

5 

6 

7__docformat__ = 'restructuredtext' 

8 

9COPYRIGHT = """This is public domain.""" 

10TITLE = """Mauna Loa Weekly Atmospheric CO2 Data""" 

11SOURCE = """ 

12Data obtained from http://cdiac.ornl.gov/trends/co2/sio-keel-flask/sio-keel-flaskmlo_c.html 

13 

14Obtained on 3/15/2014. 

15 

16Citation: 

17 

18Keeling, C.D. and T.P. Whorf. 2004. Atmospheric CO2 concentrations derived from flask air samples at sites in the SIO network. In Trends: A Compendium of Data on Global Change. Carbon Dioxide Information Analysis Center, Oak Ridge National Laboratory, U.S. Department of Energy, Oak Ridge, Tennessee, U.S.A. 

19""" 

20 

21DESCRSHORT = """Atmospheric CO2 from Continuous Air Samples at Mauna Loa Observatory, Hawaii, U.S.A.""" 

22 

23DESCRLONG = """ 

24Atmospheric CO2 from Continuous Air Samples at Mauna Loa Observatory, Hawaii, U.S.A. 

25 

26Period of Record: March 1958 - December 2001 

27 

28Methods: An Applied Physics Corporation (APC) nondispersive infrared gas analyzer was used to obtain atmospheric CO2 concentrations, based on continuous data (four measurements per hour) from atop intake lines on several towers. Steady data periods of not less than six hours per day are required; if no such six-hour periods are available on any given day, then no data are used that day. Weekly averages were calculated for most weeks throughout the approximately 44 years of record. The continuous data for year 2000 is compared with flask data from the same site in the graphics section.""" 

29 

30#suggested notes 

31NOTE = """:: 

32 

33 Number of observations: 2225 

34 Number of variables: 2 

35 Variable name definitions: 

36 

37 date - sample date in YYMMDD format 

38 co2 - CO2 Concentration ppmv 

39 

40 The data returned by load_pandas contains the dates as the index. 

41""" 

42 

43 

44def load_pandas(): 

45 data = _get_data() 

46 index = pd.date_range(start=str(data['date'][0]), periods=len(data), freq='W-SAT') 

47 dataset = data[['co2']] 

48 dataset.index = index 

49 return du.Dataset(data=dataset, names=list(data.columns)) 

50 

51 

52def load(as_pandas=None): 

53 """ 

54 Load the data and return a Dataset class instance. 

55 

56 Parameters 

57 ---------- 

58 as_pandas : bool 

59 Flag indicating whether to return pandas DataFrames and Series 

60 or numpy recarrays and arrays. If True, returns pandas. 

61 

62 Returns 

63 ------- 

64 Dataset instance: 

65 See DATASET_PROPOSAL.txt for more information. 

66 """ 

67 return du.as_numpy_dataset(load_pandas(), as_pandas=as_pandas, retain_index=True) 

68 

69def _get_data(): 

70 return du.load_csv(__file__, 'co2.csv')