diff --git a/README.md b/README.md index 0ce4578..278eeea 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Package including functions to perform GW follow-up scheduling and simulations i - useGreytime: flag to schedule greyness observations in addition to darkness - [tiling] - - online: tbd + - minimumProbCutforCatalogue: only galaxies that have probabilities higher than 'minimumProbCutforCatalogue x (GW x galaxy)_max' participate in the scheduling calculation - minProbcut: minimal probability covered per tile to schedule observation - distCut: distance cut to define the mandatory use of 2D strategy (coming from galaxy catalogue completeness) @@ -97,7 +97,7 @@ Package including functions to perform GW follow-up scheduling and simulations i - reducedNside: nside of the low-resolution skymap used as a grid to speed up the computation - HRnside: nside of the high-resolution skymap used to compute the covered probability - mangrove: flag to use the mangrove method of weighting by the mass of the host galaxy - + - countPrevious: True if you want previous observation to be considered in number to set the max run variable. False else ## Issue with Daily Earth Orientation Parameters Solutions file (finals2000A) diff --git a/examples/config/ExampleConfig.ini b/examples/config/ExampleConfig.ini index 53beca2..102b3d7 100644 --- a/examples/config/ExampleConfig.ini +++ b/examples/config/ExampleConfig.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.002 distCut = 500 diff --git a/examples/config/FollowupParameters_ATCA.ini b/examples/config/FollowupParameters_ATCA.ini index 8e06e05..db46aaa 100755 --- a/examples/config/FollowupParameters_ATCA.ini +++ b/examples/config/FollowupParameters_ATCA.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.001 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 2D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_CTAON.ini b/examples/config/FollowupParameters_CTAON.ini index daef01a..e6a4513 100755 --- a/examples/config/FollowupParameters_CTAON.ini +++ b/examples/config/FollowupParameters_CTAON.ini @@ -22,9 +22,8 @@ minDuration = 10 useGreytime = False [tiling] -online = False minimumProbCutforCatalogue = 0.01 -minProbcut = 0.02 +minProbcut = 0.002 distCut = 500 doPlot = True secondRound = False @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_CTAOS.ini b/examples/config/FollowupParameters_CTAOS.ini index 431b029..7bbd989 100755 --- a/examples/config/FollowupParameters_CTAOS.ini +++ b/examples/config/FollowupParameters_CTAOS.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.02 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = True \ No newline at end of file diff --git a/examples/config/FollowupParameters_ESO.ini b/examples/config/FollowupParameters_ESO.ini index 7306996..afd6898 100755 --- a/examples/config/FollowupParameters_ESO.ini +++ b/examples/config/FollowupParameters_ESO.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.0005 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = targeted -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_ESO2.ini b/examples/config/FollowupParameters_ESO2.ini index dd650f7..ac6d083 100755 --- a/examples/config/FollowupParameters_ESO2.ini +++ b/examples/config/FollowupParameters_ESO2.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.0005 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = targeted -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_HA.ini b/examples/config/FollowupParameters_HA.ini index 40412d9..b6516ef 100755 --- a/examples/config/FollowupParameters_HA.ini +++ b/examples/config/FollowupParameters_HA.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.0005 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = targeted -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_HESS.ini b/examples/config/FollowupParameters_HESS.ini index 959057a..315be9f 100755 --- a/examples/config/FollowupParameters_HESS.ini +++ b/examples/config/FollowupParameters_HESS.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.02 distCut = 500 @@ -33,4 +32,5 @@ percentageMOC = 0.90 reducedNside = 128 HRnside = 512 mangrove = False -algorithm = 3D \ No newline at end of file +algorithm = 3D +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LP.ini b/examples/config/FollowupParameters_LP.ini index 9448e52..203b0e2 100755 --- a/examples/config/FollowupParameters_LP.ini +++ b/examples/config/FollowupParameters_LP.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = False [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.0005 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = targeted -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LP2.ini b/examples/config/FollowupParameters_LP2.ini index c4f6e88..97cbec7 100755 --- a/examples/config/FollowupParameters_LP2.ini +++ b/examples/config/FollowupParameters_LP2.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.01 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LST.ini b/examples/config/FollowupParameters_LST.ini index 43b5f47..7aeea35 100755 --- a/examples/config/FollowupParameters_LST.ini +++ b/examples/config/FollowupParameters_LST.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = False [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.02 distCut = 500 @@ -34,4 +33,5 @@ reducedNside = 256 HRnside = 512 mangrove = False doRank= True -algorithm = 2D \ No newline at end of file +algorithm = 3D +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LST1.ini b/examples/config/FollowupParameters_LST1.ini index f575ab6..f09b728 100755 --- a/examples/config/FollowupParameters_LST1.ini +++ b/examples/config/FollowupParameters_LST1.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.01 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LST2.ini b/examples/config/FollowupParameters_LST2.ini index 2238735..f185e19 100755 --- a/examples/config/FollowupParameters_LST2.ini +++ b/examples/config/FollowupParameters_LST2.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.01 distCut = 500 @@ -35,4 +34,4 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LST3.ini b/examples/config/FollowupParameters_LST3.ini index c05a2b7..ca2427b 100755 --- a/examples/config/FollowupParameters_LST3.ini +++ b/examples/config/FollowupParameters_LST3.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.01 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_LST4.ini b/examples/config/FollowupParameters_LST4.ini index ab06c2f..e6d34d4 100755 --- a/examples/config/FollowupParameters_LST4.ini +++ b/examples/config/FollowupParameters_LST4.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.01 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_MAGIC.ini b/examples/config/FollowupParameters_MAGIC.ini index f940a0b..9aee764 100755 --- a/examples/config/FollowupParameters_MAGIC.ini +++ b/examples/config/FollowupParameters_MAGIC.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.01 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = False algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_OHP.ini b/examples/config/FollowupParameters_OHP.ini index ce56c6f..d2042a9 100755 --- a/examples/config/FollowupParameters_OHP.ini +++ b/examples/config/FollowupParameters_OHP.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut = 0.005 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = integrated -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/examples/config/FollowupParameters_SA.ini b/examples/config/FollowupParameters_SA.ini index 8853435..1540648 100755 --- a/examples/config/FollowupParameters_SA.ini +++ b/examples/config/FollowupParameters_SA.ini @@ -22,7 +22,6 @@ minDuration = 10 useGreytime = True [tiling] -online = False minimumProbCutforCatalogue = 0.01 minProbcut =0.0005 distCut = 500 @@ -35,4 +34,5 @@ HRnside = 512 mangrove = True algorithm = 3D strategy = targeted -doRank = True \ No newline at end of file +doRank = True +countPrevious = False \ No newline at end of file diff --git a/src/tilepy/include/PointingTools.py b/src/tilepy/include/PointingTools.py index 10ca0c6..ea95182 100644 --- a/src/tilepy/include/PointingTools.py +++ b/src/tilepy/include/PointingTools.py @@ -388,10 +388,11 @@ class ObservationParameters(object): def __init__(self, name=None, lat=0, lon=0, height=0, sunDown=None, moonDown=None, moonGrey=None, moonPhase=None, minMoonSourceSeparation=None, maxMoonSourceSeparation=None, maxZenith=None, FOV=None, maxRuns=None, maxNights=None, - duration=None, minDuration=None, useGreytime=None, minSlewing=None, online=False, + duration=None, minDuration=None, useGreytime=None, minSlewing=None, minimumProbCutForCatalogue=None, minProbcut=None, distCut=None, doPlot=False, secondRound=None, zenithWeighting=None, percentageMOC=None, reducedNside=None, HRnside=None, - mangrove=None, skymap=None,obsTime=None,datasetDir=None,galcatName=None,outDir=None,pointingsFile=None,alertType=None, locCut=None, MO=False, algorithm=None, strategy=None, doRank=False): + mangrove=None, skymap=None,obsTime=None,datasetDir=None,galcatName=None,outDir=None,pointingsFile=None, countPrevious=False, + alertType=None, locCut=None, MO=False, algorithm=None, strategy=None, doRank=False): self.name = name self.lat = lat @@ -419,7 +420,6 @@ def __init__(self, name=None, lat=0, lon=0, height=0, sunDown=None, moonDown=Non self.minSlewing = minSlewing # Tiling - self.online = online self.minimumProbCutForCatalogue = minimumProbCutForCatalogue self.minProbcut = minProbcut self.distCut = distCut @@ -433,6 +433,7 @@ def __init__(self, name=None, lat=0, lon=0, height=0, sunDown=None, moonDown=Non self.algorithm = algorithm self.strategy = strategy self.doRank = doRank + self.countPrevious = countPrevious # Parsed args self.skymap = skymap @@ -517,7 +518,6 @@ def from_configfile(self, filepath): self.minSlewing = float(parser.get(section, 'minslewing', fallback=0)) section = 'tiling' - self.online = (parser.getboolean(section, 'online', fallback=None)) self.minimumProbCutForCatalogue = float(parser.get( section, 'minimumprobcutforcatalogue', fallback=0)) self.minProbcut = float(parser.get(section, 'minProbcut', fallback=0)) @@ -536,11 +536,12 @@ def from_configfile(self, filepath): self.algorithm = str(parser.get(section, 'algorithm', fallback=None)) self.strategy = str(parser.get(section, 'strategy', fallback=None)) self.doRank = (parser.getboolean(section, 'doRank', fallback=None)) + self.countPrevious = (parser.getboolean(section, 'countPrevious', fallback=None)) def from_args(self, name, lat, lon, height, sunDown, moonDown, moonGrey, moonPhase, minMoonSourceSeparation, maxMoonSourceSeparation, maxZenith, FOV, maxRuns, maxNights, - duration, minDuration, useGreytime, minSlewing, online, + duration, minDuration, useGreytime, minSlewing, minimumProbCutForCatalogue, minProbcut,distCut, doPlot, secondRound, zenithWeighting, percentageMOC, reducedNside, HRnside, mangrove): @@ -572,7 +573,6 @@ def from_args(self, name, lat, lon, height, sunDown, moonDown, self.minSlewing = minSlewing # Tiling - self.online = online self.minimumProbCutForCatalogue = minimumProbCutForCatalogue self.minProbcut = minProbcut self.distCut = distCut @@ -1792,8 +1792,11 @@ def ComputeProbability2D(prob, highres, radecs, reducedNside, HRnside, minProbcu return P_GW, targetCoord, ipixlist, ipixlistHR -def SubstractPointings2D(tpointingFile, prob, nside, FOV, pixlist): - radius = FOV +def SubstractPointings2D(tpointingFile, prob, obspar, pixlist): + + nside = obspar.reducedNside + radius = obspar.FOV + print("Subtracting pointings from " + tpointingFile) ra, dec = np.genfromtxt(tpointingFile, usecols=(2, 3), dtype="str", skip_header=1, delimiter=' ', @@ -1816,7 +1819,7 @@ def SubstractPointings2D(tpointingFile, prob, nside, FOV, pixlist): P_GW.append(prob[effectiveipix_disc].sum()) print('Coordinates ra:', ra[i], 'dec:', dec[i], 'Pgw:', P_GW[i], 'vs', prob[ipix_disc].sum()) - return pixlist, np.sum(P_GW) + return pixlist, np.sum(P_GW), len(ra) ###################################################### @@ -2455,9 +2458,9 @@ def SimpleGWprob(prob, finalGals, talreadysumipixarray, FOV, nside): return probability -def SubstractPointings(tpointingFile, galaxies, talreadysumipixarray, tsum_dP_dV, FOV, prob, nside): +def SubstractPointings(tpointingFile, galaxies, talreadysumipixarray, tsum_dP_dV, prob, obspar, nside): - # targetCoord = co.SkyCoord(galaxies['RAJ2000'], galaxies['DEJ2000'], frame='fk5', unit=(u.deg, u.deg)) + FOV = obspar.FOV # Read PointingsFile @@ -2490,7 +2493,7 @@ def SubstractPointings(tpointingFile, galaxies, talreadysumipixarray, tsum_dP_dV PGAL.append(pgalcircle) print('Coordinates ra:', ra, 'dec:', dec, 'Pgw:', pgwcircle, 'PGAL:', pgalcircle) - return ra, dec, updatedGalaxies, PGW, PGAL, talreadysumipixarray + return ra, dec, updatedGalaxies, PGW, PGAL, talreadysumipixarray, len(np.atleast_1d(ra)) def SubstractGalaxiesCircle(galaux, ra, dec, talreadysumipixarray, tsum_dP_dV, FOV, prob, nside): diff --git a/src/tilepy/include/TilingDetermination.py b/src/tilepy/include/TilingDetermination.py index 4bce612..de12287 100755 --- a/src/tilepy/include/TilingDetermination.py +++ b/src/tilepy/include/TilingDetermination.py @@ -120,10 +120,18 @@ def PGWinFoV(filename,obspar,dirName): radecs = co.SkyCoord(rapix, decpix, frame='icrs', unit=(u.deg, u.deg)) # Add observed pixels to pixlist + maxRuns = obspar.maxRuns if (PointingFile != None): - pixlist, P_GW = SubstractPointings2D( - PointingFile, prob, obspar.reducedNside, obspar.FOV, pixlist) - print('Already observed probability =', P_GW) + pixlist, sumPGW, doneObs = SubstractPointings2D(PointingFile, prob, obspar, pixlist) + + if obspar.countPrevious: + maxRuns = obspar.maxRuns - doneObs + print("===========================================================================================") + print() + print(f"{name}: Total GW probability already covered: {sumPGW}") + print(f"Count Previous = {obspar.countPrevious}, Number of pointings already done: {doneObs}, " + f"Max Runs was {obspar.maxRuns}, now is {maxRuns}") + print("===========================================================================================") ####################################################### @@ -137,7 +145,7 @@ def PGWinFoV(filename,obspar,dirName): counter = 0 for j, NightDarkRun in enumerate(NightDarkRuns): - if (len(ObservationTimearray) < obspar.maxRuns): + if (len(ObservationTimearray) < maxRuns): ObservationTime = NightDarkRun ObsBool, yprob = ZenithAngleCut(prob, nside, ObservationTime, obspar.minProbcut, obspar.maxZenith, obspar.location, obspar.minMoonSourceSeparation, obspar.useGreytime) @@ -260,25 +268,27 @@ def PGalinFoV(filename,galFile,obspar,dirName): alreadysumipixarray2 = [] ######################### + maxRuns = obspar.maxRuns if (PointingFile == None): tGals = tGals0 print('No pointings were given to be substracted') else: - ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal, alreadysumipixarray1 = SubstractPointings( - PointingFile, tGals0, alreadysumipixarray1, sum_dP_dV, obspar.FOV, prob, nside) - # for second round - # ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal,alreadysumipixarray2 = SubstractPointings(PointingFile, tGals0,alreadysumipixarray1,sum_dP_dV,obspar.FOV,prob,nside) - maxRuns = obspar.maxRuns - len(np.atleast_1d(ra)) + ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal, alreadysumipixarray1, doneObs = SubstractPointings( + PointingFile, tGals0, alreadysumipixarray1, sum_dP_dV, prob, obspar, nside) sumPGW = sum(AlreadyObservedPgw) sumPGAL = sum(AlreadyObservedPgal) - + # for second round + # ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal,alreadysumipixarray2, doneObs = SubstractPointings(PointingFile, tGals0,alreadysumipixarray1,sum_dP_dV,prob, obspar, nside) + if obspar.countPrevious: + maxRuns = obspar.maxRuns - doneObs print("===========================================================================================") print() - print(name, "Total GW probability already covered: ", sumPGW, - "Total Gal probability already covered: ", - sumPGAL, "Number of effective pointings already done: ", len(np.atleast_1d(ra))) - + print(f"{name}: Total GW probability already covered: {sumPGW}, " + f"Total Gal probability already covered: {sumPGAL}") + print(f"Count Previous = {obspar.countPrevious}, Number of pointings already done: {doneObs}, " + f"Max Runs was {obspar.maxRuns}, now is {maxRuns}") + print("===========================================================================================") ########################## tGals_aux = tGals @@ -295,7 +305,7 @@ def PGalinFoV(filename,galFile,obspar,dirName): Round = [] print('---------- NEW FOLLOW-UP ATTEMPT ----------') - print('maxRuns: ', obspar.maxRuns, 'MinimumProbCutForCatalogue: ', + print('maxRuns: ', maxRuns, 'MinimumProbCutForCatalogue: ', obspar.minimumProbCutForCatalogue) if (obspar.useGreytime): @@ -308,7 +318,7 @@ def PGalinFoV(filename,galFile,obspar,dirName): counter = 0 if(obspar.strategy == 'integrated'): for j, NightDarkRun in enumerate(NightDarkRuns): - if (len(ObservationTimearray) < obspar.maxRuns): + if (len(ObservationTimearray) < maxRuns): ObservationTime = NightDarkRun visible, altaz, tGals_aux = VisibleAtTime( ObservationTime, tGals_aux, obspar.maxZenith, obspar.location) @@ -405,7 +415,7 @@ def PGalinFoV(filename,galFile,obspar,dirName): break if(obspar.strategy == 'targeted'): for j, NightDarkRun in enumerate(NightDarkRuns): - if (len(ObservationTimearray) < obspar.maxRuns): + if (len(ObservationTimearray) < maxRuns): ObservationTime = NightDarkRun visible, altaz, tGals_aux = VisibleAtTime( ObservationTime, tGals_aux, obspar.maxZenith, obspar.location) @@ -573,27 +583,29 @@ def PGalinFoV_PixRegion(filename,ObservationTime0,PointingFile,galFile, obspar,d alreadysumipixarray1 = [] alreadysumipixarray2 = [] - ######################### - + ######################### + maxRuns = obspar.maxRuns if (PointingFile == None): tGals = tGals0 print('No pointings were given to be substracted') else: # tGals_aux = tGals - ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal, alreadysumipixarray1 = SubstractPointings( - PointingFile, tGals0, alreadysumipixarray1, sum_dP_dV, obspar.FOV, prob, nside) - maxRuns = obspar.maxRuns - len(np.atleast_1d(ra)) + ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal, alreadysumipixarray1, doneObs = SubstractPointings( + PointingFile, tGals0, alreadysumipixarray1, sum_dP_dV, prob, obspar, nside) sumPGW = sum(AlreadyObservedPgw) sumPGAL = sum(AlreadyObservedPgal) # ObservedPointings = Table([time, ra, dec, AlreadyObservedPgw, AlreadyObservedPgal],names=['Time[UTC]', 'RA(deg)', 'DEC(deg)', 'Covered GW probability','Pgal covered']) # print(ObservedPointings) + if obspar.countPrevious: + maxRuns = obspar.maxRuns - doneObs print("===========================================================================================") print() - print( - name, "Total GW probability already covered: ", sumPGW, - "Total Gal probability already covered: ", - sumPGAL, "Number of effective pointings already done: ", len(np.atleast_1d(ra))) + print(f"{name}: Total GW probability already covered: {sumPGW}, " + f"Total Gal probability already covered: {sumPGAL}") + print(f"Count Previous = {obspar.countPrevious}, Number of pointings already done: {doneObs}, " + f"Max Runs was {obspar.maxRuns}, now is {maxRuns}") + print("===========================================================================================") ######################### tGals_aux = tGals @@ -614,7 +626,7 @@ def PGalinFoV_PixRegion(filename,ObservationTime0,PointingFile,galFile, obspar,d nextround = False Round = [] print('---------- NEW FOLLOW-UP ATTEMPT ----------') - print('maxRuns: ', obspar.maxRuns, 'MinimumProbCutForCatalogue: ', + print('maxRuns: ', maxRuns, 'MinimumProbCutForCatalogue: ', obspar.minimumProbCutForCatalogue) if (obspar.useGreytime): @@ -637,7 +649,7 @@ def PGalinFoV_PixRegion(filename,ObservationTime0,PointingFile,galFile, obspar,d ############################## counter = 0 for j in range(0, len(NightDarkRuns)): - if (len(ObservationTimearray) < obspar.maxRuns): + if (len(ObservationTimearray) < maxRuns): ObservationTime = NightDarkRuns[j] if (nextround): ObservationTime = NightDarkRuns[j - 1] @@ -847,12 +859,20 @@ def PGWinFoV_NObs(filename, ObservationTime0, PointingFile, obsparameters, dirNa rapix, decpix, areapix = Get90RegionPixReduced( prob, obspar.percentageMOC, obspar.reducedNside) radecs = co.SkyCoord(rapix, decpix, frame='icrs', unit=(u.deg, u.deg)) + maxRuns = obspar.maxRuns # Add observed pixels to pixlist if (PointingFile != None): print(PointingFile, prob, obspar.reducedNside, obspar.FOV, pixlist) - pixlist, P_GW = SubstractPointings2D( - PointingFile, prob, obspar.reducedNside, obspar.FOV, pixlist) - print('Already observed probability =', P_GW) + pixlist, sumPGW, doneObs = SubstractPointings2D(PointingFile, prob, obspar, pixlist) + + if obspar.countPrevious: + maxRuns = obspar.maxRuns - doneObs + print("===========================================================================================") + print() + print(f"{name}: Total GW probability already covered: {sumPGW}") + print(f"Count Previous = {obspar.countPrevious}, Number of pointings already done: {doneObs}, " + f"Max Runs was {obspar.maxRuns}, now is {maxRuns}") + print("===========================================================================================") ################################################################################################################################################# ITERATION_OBS = 0 TIME_MIN_ALL = [] @@ -877,7 +897,7 @@ def PGWinFoV_NObs(filename, ObservationTime0, PointingFile, obsparameters, dirNa ITERATION_OBS = 0 ITERATION_OBS += 1 - if(couter_per_obs[j] >= obspar.maxRuns): + if(couter_per_obs[j] >= maxRuns): SameNight[j] = False if (TIME_MIN >= NewActiveObsTime[j]) & SameNight[j]: ObsBool, yprob = ZenithAngleCut(prob, nside, ObservationTime, obspar.minProbcut, @@ -1038,16 +1058,26 @@ def PGalinFoV_NObs(filename, ObservationTime0, PointingFile, galFile, obsparamet prob, distmu, distsigma, thisDistance, thisDistanceErr, distnorm, cat, has3D, obspar.minimumProbCutForCatalogue) # Add observed pixels to pixlist + maxRuns = obspar.maxRuns if (PointingFile == None): tGals = tGals0 print('No pointings were given to be substracted') else: # tGals_aux = tGals - ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal, alreadysumipixarray1 = SubstractPointings( - PointingFile, tGals0, alreadysumipixarray1, sum_dP_dV, obspar.FOV, prob, nside) + ra, dec, tGals, AlreadyObservedPgw, AlreadyObservedPgal, alreadysumipixarray1, doneObs= SubstractPointings( + PointingFile, tGals0, alreadysumipixarray1, sum_dP_dV, prob, obspar, nside) maxRuns = obspar.maxRuns - len(ra) sumPGW = sum(AlreadyObservedPgw) sumPGAL = sum(AlreadyObservedPgal) + if obspar.countPrevious: + maxRuns = obspar.maxRuns - doneObs + print("===========================================================================================") + print() + print(f"{name}: Total GW probability already covered: {sumPGW}, " + f"Total Gal probability already covered: {sumPGAL}") + print(f"Count Previous = {obspar.countPrevious}, Number of pointings already done: {doneObs}, " + f"Max Runs was {obspar.maxRuns}, now is {maxRuns}") + print("===========================================================================================") tGals_aux = tGals tGals_aux2 = tGals @@ -1077,7 +1107,7 @@ def PGalinFoV_NObs(filename, ObservationTime0, PointingFile, galFile, obsparamet ITERATION_OBS = 0 ITERATION_OBS += 1 - if(couter_per_obs[j] >= obspar.maxRuns): + if(couter_per_obs[j] >= maxRuns): SameNight[j] = False if (TIME_MIN >= NewActiveObsTime[j]) & SameNight[j]: diff --git a/src/tilepy/tools/ProbComputationTools.py b/src/tilepy/tools/ProbComputationTools.py index 5700d30..b0c00d7 100644 --- a/src/tilepy/tools/ProbComputationTools.py +++ b/src/tilepy/tools/ProbComputationTools.py @@ -31,9 +31,8 @@ def ComputeCoveredProbability(GWFile, PointingsFile, galFile="../dataset/GLADEpl tGals0, sum_dP_dV = CorrelateGalaxies_LVC( prob, distmu, distsigma, distnorm, cat, has3D, MinimumProbCutForCatalogue) - # alreadysumipixarray,AlreadyObservedPgw = SubstractPointings2D(PointingsFile,prob, nside, FOV,alreadysumipixarray) - ra, dec, tGals, alreadyObservedPgw, alreadyObservedPgal, alreadysumipixarray = SubstractPointings( - PointingsFile, tGals0, alreadysumipixarray, sum_dP_dV, FOV, prob, nside) + ra, dec, tGals, alreadyObservedPgw, alreadyObservedPgal, alreadysumipixarray, doneObs = SubstractPointings( + PointingsFile, tGals0, alreadysumipixarray, sum_dP_dV, prob, obspar, nside) print('Total PGW covered: ', sum(alreadyObservedPgw)) print('Total PGAL covered: ', sum(alreadyObservedPgal))