Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybaptista committed Jul 21, 2023
2 parents 04c0282 + 0e528c8 commit 5c42aa3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: [3.8, 3.9]
python: ['3.9','3.10']
toxenv: [test, test-alldeps, test-astropydev]
steps:
- name: Check out repository
Expand Down
19 changes: 15 additions & 4 deletions zdm/real_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,26 @@ def set_state(alpha_method=1, cosmo=Planck18):
return state


def surveys_and_grids(init_state=None, alpha_method=1, add_20220610A=False):
""" Load up a survey and grid for a CRACO mock dataset
def surveys_and_grids(init_state=None, alpha_method=1,
survey_names=None,
add_20220610A=False,
nz:int=2000, ndm:int=5600):
""" Load up a survey and grid for a real dataset
Args:
init_state (State, optional):
Initial state
survey_name (str, optional): Defaults to 'CRAFT/CRACO_1_5000'.
state_dict (dict, optional):
Used to init state instead of alpha_method, lum_func parameters
survey_names (list, optional):
List of surveys to load
add_20220610A (bool, optional):
Include this FRB (a bit of a hack)
nz (int, optional):
Number of redshift bins
ndm (int, optional):
Number of DM bins
Raises:
IOError: [description]
Expand All @@ -114,11 +123,13 @@ def surveys_and_grids(init_state=None, alpha_method=1, add_20220610A=False):

# get the grid of p(DM|z)
zDMgrid, zvals,dmvals = misc_functions.get_zdm_grid(
state, new=True, plot=False, method='analytic', nz=2000, ndm=5600,
state, new=True, plot=False, method='analytic',
nz=nz, ndm=ndm,
datdir=resource_filename('zdm', 'GridData'))

############## Initialise surveys ##############
survey_names = ['CRAFT/FE',
if survey_names is None:
survey_names = ['CRAFT/FE',
'CRAFT_ICS_1632',
'CRAFT_ICS_892',
'CRAFT_ICS_1272',
Expand Down
3 changes: 2 additions & 1 deletion zdm/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,6 @@ def load_survey(survey_name:str, state:parameters.State,
Returns:
Survey: instance of the class
"""
print(f"Loading survey: {survey_name}")
if sdir is None:
sdir = os.path.join(
resource_filename('zdm', 'data'), 'Surveys')
Expand Down Expand Up @@ -1017,6 +1016,8 @@ def load_survey(survey_name:str, state:parameters.State,
else:
dfile += '.ecsv'

print(f"Loading survey: {survey_name} from {dfile}")

# Do it
if original:
srvy=OldSurvey()
Expand Down
49 changes: 14 additions & 35 deletions zdm/tests/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas

from zdm import iteration as it
from zdm.craco import loading
from zdm import real_loading
from zdm import io
from zdm.tests import tstutils

Expand All @@ -30,16 +30,23 @@ def test_cube_run():
# Initialise survey and grid
# For this purporse, we only need two different surveys
#names=['CRAFT/FE','CRAFT/ICS','CRAFT/ICS892','CRAFT/ICS1632','PKS/Mb']
names=['CRAFT/FE','CRAFT/ICS','CRAFT/ICS892','PKS/Mb']
sdir = os.path.join(resource_filename('zdm', 'data'), 'Surveys')
surveys=[]
grids=[]
names=['CRAFT/FE','CRAFT/ICS','CRAFT/ICS892',
'PKS/Mb']
#sdir = os.path.join(resource_filename('zdm', 'data'), 'Surveys')
#surveys=[]
#grids=[]

'''
# We should be using real_loading
for name in names:
# We should be using real_loading
s,g = loading.survey_and_grid(
survey_name=name,NFRB=None,sdir=sdir) # should be equal to actual number of FRBs, but for this purpose it doesn't matter
surveys.append(s)
grids.append(g)
'''
surveys, grids = real_loading.surveys_and_grids(
survey_names=names,
nz=500, ndm=1400) # Small number to keep this cheap


### gets cube files
Expand Down Expand Up @@ -108,33 +115,5 @@ def test_cube_run():
zdm_v2= ds.p_DMgz + ds.p_z
assert check_accuracy(zdm_v1,zdm_v2)

'''
# now check it has the right dimensions
with open(outfile, 'r') as infile:
lines=infile.readlines()
assert len(lines)==howmany+1
for i,line in enumerate(lines):
if i==0:
colmns = line.split(',')
continue
words=line.split(',')
embed(header='106 of test_cube')
# three ways of calculating lltot
lltot_v0=float(words[-8])
lltot_v1=0
for j in np.arange(ns):
lltot_v1 += float(words[9+5*j])
lltot_v2=float(words[-5])+float(words[-6])+float(words[-7])
# three ways of calculating p(z,DM)
zdm_v1=float(words[-3])+float(words[-4])
zdm_v2=float(words[-1])+float(words[-2])
assert check_accuracy(zdm_v1,zdm_v2)
assert check_accuracy(lltot_v0,lltot_v1)
assert check_accuracy(lltot_v0,lltot_v2)
'''

#test_cube_run()
#test_cube_run()

0 comments on commit 5c42aa3

Please sign in to comment.