from irfpy.swim.SwimGfact import *
def main():
# logging.getLogger().setLevel(logging.DEBUG)
logging.debug('Main test routine of GFACTOR.')
import numpy
# Obtain g-factor
gfact=gfactor()
g=numpy.array(gfact.getAbsGProtonStart()[1])
# Obtain energy step
import irfpy.swim.SwimEnergy as SwimEnergy
etbl=SwimEnergy.EnergyTable.table(version=2)
e=etbl.getTable()
print(e)
### Obtain data
from irfpy.swim.swim_start import getdata
import datetime
dat=getdata(datetime.datetime(2009,1,25,14,0,0)) # E=16xD=16 matrix
print(dat)
jd=dat.getJd()
cnt=numpy.array(dat.getData())
print(cnt.shape)
### Duty time
from irfpy.swim.SwimTime import duty_time
### Differential energy flux [#/cm2 sr eV s] is caclulated by C / (G E dt)
flx = cnt.copy()
print(g)
for ie in range(16):
flx[ie, :] = cnt[ie,:] / ( g * e[ie] * duty_time())
print(flx)
if __name__ == '__main__':
main()