Commit 96a2932f authored by Stefano Covino's avatar Stefano Covino
Browse files

180524 commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+10 −0
Original line number Diff line number Diff line
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
dist/*
Docs/*
Misc/*

LICENSE.txt

0 → 100644
+19 −0
Original line number Diff line number Diff line
Copyright (c) 2016 The Python Packaging Authority (PyPA)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

MANIFEST.in

0 → 100644
+20 −0
Original line number Diff line number Diff line
# Include the README
include ./README.md

# Include the license file
include ./LICENSE.txt

# Include the data files
recursive-include SRP/SRPData/ *
include SRP/SRPCalFlux.data

# Include all python files
recursive-include . *.py

# Exclude MacOS files
recursive-exclude . .DS_Store

# Exclude working files
recursive-exclude build
recursive-exclude Misc

README.md

0 → 100644
+9 −0
Original line number Diff line number Diff line
# Swift Reduction Package


The Swift Reduction Package (hereafter SRP) is a packet of command line tools to solve problems (e.g. basic reduction and analysis tasks of optical/NIR astronomical data, quick cosmological computations, units conversions, etc.) often met in astronomical research activities.

SRP was originally developed in the context of the Swift follow-up activities of the Milan GRB team at the INAF/Brera Astronomical Observatory. The package is designed to be an aid to any researcher to drive further observation of a followed-up GRB counterpart and “swift” can therefore be read simply as “rapid”, “agile”, etc.
 
 Some technical comment
 This package, written in Python (v. 3.x), has been widely tested only on PC-Linux and on Mac OS X workstations. 

SRP/SRPAfterglow.py

0 → 100644
+111 −0
Original line number Diff line number Diff line
""" Utility functions and classes for SRP

Context : SRP
Module  : SRPAfterglow.py
Version : 1.0.0
Status  : approved
Author  : Stefano Covino
Date    : 27/02/2007
E-mail  : stefano.covino@brera.inaf.it
URL     : http://www.merate.mi.astro.it/covino
Purpose : Collection of utility functions and classes for SRP.

Usage   : to be imported

Remarks : Data from Zhang & Meszaros, IJMPA A19, 2385 (2004) and
        : Hurley, Sari and Djorgovski, in "Compact Stellar X-ray Sources".

History : (27/02/2007) First version.
"""


#import SRPFiles, SRPConstants
#import os, string, math, copy
#import TimeAstro_algs
#import stats




def TypSynchrFreqConst (epse=0.1, epsb=0.01, energy=1e52, time=1, z=1):
 csie=1
 return 6*1e15 * (1+z)**0.5 * (energy/1e52)**0.5 * (epse/csie)**2 * (epsb)**0.5 * (time)**-1.5

def CoolSynchrFreqConst (epsb=0.01, energy=1e52, time=1, z=1, density=1):
 return 9*1e12 * (1+z)**-0.5 * (energy/1e52)**-0.5 * (density)**-1 * (epsb)**-1.5 * (time)**-0.5

def SelfAbsSynchrFreqConst (epse=0.1, epsb=0.01, energy=1e52, density=1, z=1):
 csie=1
 return 2*1e9 * (1+z)**-1 * (energy/1e52)**0.2 * (epse/csie)**-1 * (epsb)**0.2 * density**0.4

def TypSynchrFluxConst (epsb=0.01, energy=1e52, ldist=1e28, density=1, z=1):
 return 20 * (1+z) * (epsb)**0.5 * density**0.5 * (energy/1e52) * (ldist/1e28)**-2

def SynchrSpectrConst (nu, epse=0.1, epsb=0.01, energy=1e52, time=1, z=1, density=1, ldist=1e28, p=2.2):
 ntyp = TypSynchrFreqConst (epse, epsb, energy, time, z)
 nsabs = SelfAbsSynchrFreqConst (epse, epsb, energy, density, z)
 ncool = CoolSynchrFreqConst (epsb, energy, time, z, density)
 normfl = TypSynchrFluxConst (epsb, energy, ldist, density, z)
 if ntyp < ncool:
  if nu < nsabs:
   return normfl * (nsabs/ntyp)**(1.0/3.0) * (nu/nsabs)**2
  elif nsabs <= nu < ntyp:
   return normfl * (nu/ntyp)**(1.0/3.0)
  elif ntyp <= nu < ncool:
   return normfl * (nu/ntyp)**((1-p)/2.0)
  else:
   return normfl * (ncool/ntyp)**((1-p)/2.0) * (nu/ncool)**(-p/2.0)
 else:
  if nu < nsabs:
   return normfl * (nsabs/ncool)**(1.0/3.0) * (nu/nsabs)**2
  elif nsabs <= nu < ncool:
   return normfl * (nu/ncool)**(1.0/3.0)
  elif ncool <= nu < ntyp:
   return normfl * (nu/ncool)**-0.5
  else:
   return normfl * (ntyp/ncool)**-0.5 * (nu/ntyp)**(-p/2.0)




# \rho R^2 = Astar * 5 x 10^11  gr/cm
def TypSynchrFreqWind (epse=0.1, epsb=0.01, energy=1e52, time=1, z=1):
 csie=1
 return 1.7*1e14 * (1+z)**0.5 * (energy/1e52)**0.5 * (epse/csie)**2 * (epsb)**0.5 * (time)**-1.5

def CoolSynchrFreqWind (epsb=0.01, energy=1e52, time=1, z=1, Astar=1):
 return 7*1e11 * (1+z)**-1.5 * (energy/1e52)**0.5 * (Astar)**-2 * (epsb)**-1.5 * (time)**0.5

def SelfAbsSynchrFreqWind (epse=0.1, epsb=0.01, energy=1e52, Astar=1, z=1, time=1):
 csie=1
 return 1.5*1e10 * (1+z)**-0.4 * (energy/1e52)**-0.4 * (epse/csie)**-1 * (epsb)**0.2 * Astar**1.2 * (time)**-0.4

def TypSynchrFluxWind (epsb=0.01, energy=1e52, ldist=1e28, Astar=1, z=1, time=1):
 return 180 * (1+z)**1.5 * (epsb)**0.5 * Astar * (energy/1e52)**0.5 * (ldist/1e28)**-2 * (time)**-0.5

def SynchrSpectrWind (nu, epse=0.1, epsb=0.01, energy=1e52, time=1, z=1, Astar=1, ldist=1e28, p=2.2):
 ntyp = TypSynchrFreqWind (epse, epsb, energy, time, z)
 nsabs = SelfAbsSynchrFreqWind (epse, epsb, energy, Astar, z, time)
 ncool = CoolSynchrFreqWind (epsb, energy, time, z, Astar)
 normfl = TypSynchrFluxWind (epsb, energy, ldist, Astar, z, time)
 if ntyp < ncool:
  if nu < nsabs:
   return normfl * (nsabs/ntyp)**(1.0/3.0) * (nu/nsabs)**2
  elif nsabs <= nu < ntyp:
   return normfl * (nu/ntyp)**(1.0/3.0)
  elif ntyp <= nu < ncool:
   return normfl * (nu/ntyp)**((1-p)/2.0)
  else:
   return normfl * (ncool/ntyp)**((1-p)/2.0) * (nu/ncool)**(-p/2.0)
 else:
  if nu < nsabs:
   return normfl * (nsabs/ncool)**(1.0/3.0) * (nu/nsabs)**2
  elif nsabs <= nu < ncool:
   return normfl * (nu/ncool)**(1.0/3.0)
  elif ncool <= nu < ntyp:
   return normfl * (nu/ncool)**-0.5
  else:
   return normfl * (ntyp/ncool)**-0.5 * (nu/ntyp)**(-p/2.0)