Permalink
Browse files

Initial commit

  • Loading branch information...
hombit committed Dec 23, 2015
0 parents commit 9885aecb3027684b6fc10bd1ed6abcd5e901029d
Showing with 1,218 additions and 0 deletions.
  1. +159 −0 .gitignore
  2. +42 −0 chen_mean.py
  3. +235 −0 fred.cpp
  4. +59 −0 fred.py
  5. +332 −0 fredlib.py
  6. +255 −0 nonlinear_diffusion.cpp
  7. +51 −0 nonlinear_diffusion.hpp
  8. +67 −0 spectrum.cpp
  9. +18 −0 spectrum.hpp
@@ -0,0 +1,159 @@

# Created by https://www.gitignore.io/api/python,linux,osx,vim,c++

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/


### Linux ###
*~

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*


### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~


### C++ ###
# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app


### My ###

# Data and results
data*/
results/
obs/
X-ray_novae_modeling
*.dat
*.pdf
*.png
*.txt

# Bin
fred

# Mathematica notebooks
*.nb
@@ -0,0 +1,42 @@
#!/usr/bin/env python3


import numpy as np
from functools import reduce


def lcmean( source, dest, interval=1 ):
names = ['TJD', 'DoY', 'DaP', 'flux', 'err']
s = np.genfromtxt( source, skip_header=10, names=names, usecols=tuple(range(5)) )

tjd = s['TJD'][0]
interval_set = []
d = np.zeros( s.shape, dtype=s.dtype )
n_d = 0
for x in s:
if x['TJD'] < tjd + interval:
interval_set.append(x)
else:
n_set = len(interval_set)
if n_set == 1:
d[n_d] = x
else:
interval_set = np.array( [interval_set], dtype=s.dtype )
for name in names[:3]:
d[name][n_d] = interval_set[name].mean()
sigma2 = interval_set['err']**2
p = ( 1. / sigma2 ).sum()
d['flux'][n_d] = ( interval_set['flux'] / sigma2 ).sum() / p
d['err'][n_d] = sqrt(1. / p) + np.sqrt( ( (interval_set['flux'] - d['flux'][n_d])**2 / sigma2 ).sum() / p / (n_set-1) )
n_d += 1
tjd = np.ceil( x['TJD'] )
interval_set = [x]

with open(dest, 'w') as fd:
fd.write(
'# ' + reduce( lambda x,y: '{} {}'.format(x,y), names ) + '\n'
)
for i in range(n_d):
fd.write(
reduce( lambda x,y: '{} {}'.format(x,y), d[i] ) + '\n'
)
Oops, something went wrong.

0 comments on commit 9885aec

Please sign in to comment.