Skip to main content

This is a program of data selection and curve fitting by a digital filtering technique including Reinsch-type cubic spline, Fourier harmonics and linear interpolation. It is to derive the fitted curve to the observed data ( CO2, d13C,..), as well as to separate the seasonal, short- and long-term variations from the data.

Project description

n97fit: Curve fitting tool for trace gas observations

As known as "Nakazawa-fitting"

Reference Paper

Nakazawa, T., Ishizawa, M., Higuchi, K. And Trivett, N.B.A. (1997), Two Curve Fitting Methods Applied to CO2 Flask Data. Environmetrics, 8: 197-218. URL

Authors

  • Takakiyo Nakazawa - Original work

See the AUTHORS file for details

License

This project is licensed under the BSD 3-clause License - see the LICENSE file for details

Acknowledgments

We would like to thank Prof. Shinji Morimoto and the staff and students of the Center for Atmospheric and Oceanic Studies in Tohoku University, who contributed to the improvement of this tool.

How to use

Prerequisites

  • python >= 3.8
  • numpy
  • pandas

Running as a module

$> python -m n97fit [input_file] [config_file] [output_dir]

Input data format

YYYYMMDD obsID   Lat   Lon   Hgt    Value  Anl.Date QF
19891011  2135    13   144     2   131.17  19891023 -1
19891012  2137    15   152     2   167.82  19891023  0
...

YYYY     : Observation year
MM       : Observation month
DD       : Observation day
obsID    : Observation ID (e.g. Flask number)
Lat      : Latitude
Log      : Longtitude
Hgt      : Altitude
Value    : Time series of concentration, isotope ratio, etc.
Anl.Date : Analyzing/extracting day
QF       : Quality flag

Outputs

  • data_all.txt : All of the input data
  • data_eff_ave.txt : Input data, averaged good quality data (flag=0) by "Range of day"
  • data_eq_ave.txt : Input data, averaged and aligned to the output interval of fitting results
  • data_rej.txt : Input data, outliers
  • fit_all.txt : Fitting results
  • fit_annual.txt : Fitting results, annual mean
  • fit_monthly.txt : Fitting results, monthly mean
  • fit_multimonth.txt : Fitting results, multi-monthly mean
  • fit_onemonth.txt : Fitting results, one harmonics
  • fit_period.txt : Fitting results, mean of the whole period

Release Notes

2024-04-01

  • Version 1.0.1
  • Initial release of python version

Original Release Notes (FORTRAN version)

Program : lsfbf4-9-2.f

      This is a program of data selection and curve fitting
   by a digital filtering technique including Reinsch-type cubic
   spline, Fourier harmonics and linear interpolation. It is to
   derive the fitted curve to the observed data ( CO2, d13C,..),
   as well as to separate the seasonal, short- and long-term
   variations from the data.

      The average seasonal cycle is represented by harmonics
   (NH=0-6), but if you give NH, the average cycle with NH+1 is
   first calculated and then smoothed by a Butterworth filter
   which attenuates signals with a period of NH+1 to 50 %.
      Linear interpolation is used to calculate equally spaced
   data from residuals which are obtained by extracting the
   average seasonal cycle from actual data.
      The long-term trend and irregular parts of the seasonal
   cycle are driven by smoothing equally spaced data ,obtained
   above, with the Butterworth filter.  The extrapolated data
   for the trend and overall fit are given by the fit to the
   actual data with a Reinsch spline (T5=1825days), which are
   altered by an iterative procedure.
      Prior to use of this program, the number of harmonics has
   to be determined by the program 'PERI'.  The digital filter
  form of Reinsch spline is shown explicitly by the programs
   'COX1' or 'COX' in which the transfer function is plotted.

      KD must be sufficiently larger than the value of ((910
   +2920)/(mean data interval expressed in day)+data number of
   the record). KO must be sufficiently larger than the value
   of (910+2920+length of the data record expressed in day).
   If you want to change KD, you must change KD of subroutine
   or function Fourier, Frc1, Reinsch, Setup, Chol1d, Smooth,
   Extrad1 and Judge1,too.  If you want to change KO, you must
   change N or KO in subroutines Bwf, Scycle, Yac and Judge1,
   too.

                             By T. Nakazawa (Mar. 8, 1991)

* Before digital filtering, data values with more than 3 standard
 errors of estimated fit are identified as outliers and rejected
 from further analysis. (dafault setting)

* The order of Butterworth filter is set to be 26th for long-term
 and to be 16th for seasonal cycle. (dafault setting)

                            Last modified by M. Ishizawa
                                             (Feb. 4, 2002)

Fortran 90 version refactoring
                    Developed by Hisashi Yashio (2008)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

n97fit-1.0.2.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

n97fit-1.0.2-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file n97fit-1.0.2.tar.gz.

File metadata

  • Download URL: n97fit-1.0.2.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for n97fit-1.0.2.tar.gz
Algorithm Hash digest
SHA256 352aa2e097e6850e8d8895768f66fdef6b06c9a55dc99aff60a576adba3d1265
MD5 3842f8104e889bbf2548fe290dfbbf6e
BLAKE2b-256 2900edb569e33ec9edb0a9488ac8812e77c70b8a79523d8593067b6f1602498f

See more details on using hashes here.

File details

Details for the file n97fit-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: n97fit-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for n97fit-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea26018dcaf08f48e22b70e9bb60fb58965205d35fb230076bbb8d271bc563b9
MD5 ea1dc8815ddbde2cdc9ba224a11b687f
BLAKE2b-256 25775abe47de0bb89e8104fa39f183f4ba97699562d3d7b6488d1a233ed58b69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page