Giter VIP home page Giter VIP logo

wwz's Introduction

WWZ Transform Code for Python

This is a Python code for timeseries analysis using WWZ transformations. It uses Foster's abbreviated Morlet Wavelet to analyse timeseries using a WWZ (Weighted Wavelet-Z) transform. (Foster, G., 1996, http://adsabs.harvard.edu/full/1996AJ....112.1709F)

The algoritm is mostly translated from Templeton's Fortran code (Templeton, M., 2004, http://adsabs.harvard.edu/full/2004JAVSO..32...41T).

Details of the mathematics, coding and fundamental time series analysis (especially in astronomy) is available in my thesis (Turkish): http://eayd.in/msc

Citing This Code

You can cite this code with its DOI and citing my thesis:

DOI

Aydin, M. E., 2017. eaydin/WWZ: v1.0.0, Zenodo, http://doi.org/10.5281/zenodo.375648

Aydin, M. E., 2014, Dynamic Power Spectra On The Basis Of Wavelet Transform, M.S. Thesis, Ankara University

Usage

It can either be used as a module import in another Python script or used as a standalone program. It supports paralellization, yet only in standalone mode.

Dependencies: Python 2.6+ (not Python 3 ready) and NumPy

There is also a Lomb-Scargle script in the repo for ease of use and comparison.

usage: wwz.py [-h] -f FILE -o OUTPUT -l FREQ_LOW -hi FREQ_HIGH -d FREQ_STEP -c
          DCON [-g] [-m] [-t TIME_DIVISIONS] [--time] [--no-headers]
          [-p PARALLEL]
          
Input arguments can be read from a file. The file descriptor
    prefix is '@'.
In order to read argument from a file named args.txt,
    the argument @args.txt should be passed.
An example for args.txt:

    -f=myinputfile.txt
    -o=theoutputfile.output
    -m
    --freq-step=0.001
    -l=0.001
    -hi=0.01
    -c=0.001
    -p=0

You can pass arguments from file and commandline at the same time.
If two same arguments passed by this method, the latter will be
used. So if you want to override some arguments in a an argument
file, specify the file first.
An example usage for our earlier @args.txt is as:

    python wwz.py @args.txt -c=0.0125

The above command will use the settings in args.txt but will
use c=0.0125 instead of c=0.001

Comments and blank lines are NOT allowed in argument files.

Import this script via Python to use it as a module, rather than
a standalone script. (import wwz)

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  the Input File, Raw Lightcurve
  -o OUTPUT, --output OUTPUT
                        the Output File Name
  -l FREQ_LOW, --freq-low FREQ_LOW
                        the Low Frequency Value
  -hi FREQ_HIGH, --freq-high FREQ_HIGH
                        the High Frequency Value
  -d FREQ_STEP, --freq-step FREQ_STEP
                        the dF value, incremental step for Frequency
  -c DCON, --dcon DCON  the C constant for the Window Function
  -g, --gnuplot-compatible
                        the Output file is GNUPlot compatible, which means the
                        tau's will be grouped so that pm3d can easily map.
                        Default value is 'False'.
  -m, --max-periods     Creates a secondary output with the maximum Periods
                        for each single tau. This can be drawn in 2D. The
                        output filename is derived from the -o option, added
                        'max_periods'. Default value is 'False'.
  -t TIME_DIVISIONS, --time-divisions TIME_DIVISIONS
                        The Time Divisions value. Templeton assumes this as
                        50. VStars from AAVSO leaves this optional contrary to
                        Templeton, yet it's default value is also 50.
  --time                Calculate the time of operation in seconds and print
                        to standard output.
  --no-headers          Doesn't print headers to output files if set. Default
                        is 'False'.
  -p PARALLEL, --parallel PARALLEL
                        Created threads to speed up the process. Default value
                        is '1', which means single thread. '0' means number of
                        detected CPUs, can be overridden.

Example Outputs

Below is an example of the X-Ray source (observed by the RXTE Satellite) with data, Lomb-Scargle and WWZ output.

Example Graph

The example below shows the main advantage of WWZ over LS. There is periodicity that LS failed to detect, with a period of about 166 days. Also note the change in frequency.

Sco X-1

The SMCX-1 graph below shows how peak frequency detected by LS can be misleading, since that frequency value actually changes (very low at 51500 and 54500 MJD) and the alias of the detected LS peak (at around 29 days period) is not detected by the WWZ algorithm (which is a good thing).

SMCX-1

wwz's People

Contributors

eaydin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wwz's Issues

Problem regarding running WWZ: raising ValueError

Prof. Aydin,
I am attempting to apply the weighted wavelet transform to one AGN dataset, but I am getting the following error:

Traceback (most recent call last):
File "wwz.py", line 1112, in
args.no_headers, args.max_periods)
File "wwz.py", line 468, in writefile
numpy.set_printoptions(threshold='nan')
File "/home/anuvab/anaconda3/envs/py2/lib/python2.7/site-packages/numpy/core/arrayprint.py", line 246, in set_printoptions
floatmode, legacy)
File "/home/anuvab/anaconda3/envs/py2/lib/python2.7/site-packages/numpy/core/arrayprint.py", line 93, in _make_options_dict
raise ValueError("threshold must be numeric and non-NAN, try "
ValueError: threshold must be numeric and non-NAN, try sys.maxsize for untruncated representation

The lightcurve and args.txt files are attached. Could you kindly let me know the reason behind the error, and how to circumvent it? In particular, is it because of incorrect low and high-frequency values? Could you kindly let me know how to decide on these frequencies for a particular dataset? It would be really helpful.

regards,
Anuvab Banerjee
SNBNCBS
India

args.txt
lc2.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.