Closed louisbondonneau closed 3 years ago
def extract_psr_param(parameters, string):
"""
extraction of a single parameter from a string of parameters
parameters = "FOLD: --TFOLD=10.737 --DEFARADAY --SRC=J0828+53"
return a liste of 2 elements: a booleen True if the wanted string is find
and and the value or the default value
"""
beg = parameters.find(string)
if (beg == -1):
if(string == "--TFOLD="):
return [False, '10.73741824']
if(string == "--NBINS="):
return [False, '2048']
if(string == "--NBITS="):
return [False, '32']
if(string == "--DSTIME="):
return [False, '128']
if(string == "--ONLYI"):
return [False, '']
if(string == "--ONLYI"):
return [True, '']
beg += len(string)
param = parameters[beg:].split()[0]
return [True, param]
def data_size(parameters, nchan=192, duration=3600):
duration -= 60 # burning time at start
MODE = parameters.split(':')[0]
if (MODE=='TF'): # TF mode
print('this is tf mode')
size = 0
elif (MODE=='FOLD'): # FOLD mode
nbit = 32
tfold = float(extract_psr_param(parameters, '--TFOLD=')[1])
npol = extract_psr_param(parameters, '--ONLYI')
nbin = float(extract_psr_param(parameters, '--NBINS=')[1])
if(npol[0]):
npol = 1
else:
npol = 4
size = (float(duration)/tfold ) * nchan * npol * nbit * nbin / 8 # Bytes
elif (MODE=='SINGLE'): # SINGLE mode
dstime = float(extract_psr_param(parameters, '--DSTIME=')[1])
nbit = float(extract_psr_param(parameters, '--NBITS=')[1])
npol = extract_psr_param(parameters, '--ONLYI')
if(npol[0]):
npol = 1
else:
npol = 4
size = nbit*npol*nchan*(float(duration)/5.12e-6/dstime)/8 # Bytes
elif (MODE=='WAVE'): # WAVE mode
npol = 4
size = 8*npol*nchan*(float(duration)/5.12e-6)/8 # Bytes
elif (MODE=='WAVEOLAF'): # WAVEOLAF mode
size = 451590 * nchan * float(duration) # Bytes (aproximation due to the compression algo)
else: # default TF mode
print('default is tf mode')
size = 0
return size # size in Byte
parameters = "TF: DF=1.52 DT=10.0 HAMM"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
parameters = "FOLD: --TFOLD=10.737 --DEFARADAY --SRC=J0828+53"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
parameters = "SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64 --ONLYI --NBITS=8"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
parameters = "SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64 --ONLYI"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
parameters = "SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
parameters = "WAVEOLAF: --SRC=J0828+53"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
parameters = "WAVE: --SRC=J0828+53"
print("%s %.2f GB" % (parameters, data_size(parameters)/1e9))
this is tf mode TF: DF=1.52 DT=10.0 HAMM 0.00 GB FOLD: --TFOLD=10.737 --DEFARADAY --SRC=J0828+53 2.07 GB SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64 --ONLYI --NBITS=8 2.07 GB SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64 --ONLYI 8.30 GB SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64 33.19 GB WAVEOLAF: --SRC=J0828+53 306.94 GB WAVE: --SRC=J0828+53 531.00 GB
---------------------------------------------------------------------
parameters = "FOLD: --TFOLD=10.737 --DEFARADAY --SRC=J0828+53"
#
duration in sec
nchan
TFOLD in sec (default is 10.737)
NPOL (default is 4)
NBIN (default is 2048)
#
if (--ONLYI): NPOL=1
#
size = (duration/TFOLD ) nchan NPOL 32 NBIN/8. # Bytes
#
---------------------------------------------------------------------
#
parameters = "SINGLE: --SEARCH --DSTIME=128 --DEFARADAY --SRC=J0205+6449"
parameters = "SINGLE: --SEARCH --SRC=B0531+21 --DSTIME=64 --ONLYI"
# #
NPOL (default is 4)
#
if (--ONLYI): NPOL=1
DSTIME in sample (default is 128)
#
size = 32NPOLnchan*(duration/5.12e-6/DSTIME)/8 # Bytes
#
---------------------------------------------------------------------
#
parameters = "WAVE:"
#
nchan
duration in sec
size = 84nchan*(duration/5.12e-6)/8 # Bytes
#
---------------------------------------------------------------------
#
parameters = "WAVEOLAF:"
#
size = 451590 nchan duration # Bytes