Skip to main content

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)

Release files for n97fit 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for n97fit 1.0.2
File Size Uploaded
n97fit-1.0.2.tar.gz 23.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for n97fit 1.0.2
File Interpreter ABI Platform
n97fit-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size:47.9 kB

Release files / n97fit-1.0.2.tar.gz

Download URL n97fit-1.0.2.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
352aa2e097e6850e8d8895768f66fdef6b06c9a55dc99aff60a576adba3d1265
BLAKE2b-256 checksum
How to use checksums
2900edb569e33ec9edb0a9488ac8812e77c70b8a79523d8593067b6f1602498f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / n97fit-1.0.2-py3-none-any.whl

Download URL n97fit-1.0.2-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea26018dcaf08f48e22b70e9bb60fb58965205d35fb230076bbb8d271bc563b9
BLAKE2b-256 checksum
How to use checksums
25775abe47de0bb89e8104fa39f183f4ba97699562d3d7b6488d1a233ed58b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page