diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 4f12b4a0..705fc2e6 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -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 diff --git a/zdm/real_loading.py b/zdm/real_loading.py index 802608b5..8ededaf0 100644 --- a/zdm/real_loading.py +++ b/zdm/real_loading.py @@ -84,8 +84,11 @@ 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): @@ -93,8 +96,14 @@ def surveys_and_grids(init_state=None, alpha_method=1, add_20220610A=False): 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] @@ -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', diff --git a/zdm/survey.py b/zdm/survey.py index 874d7b0c..36788194 100644 --- a/zdm/survey.py +++ b/zdm/survey.py @@ -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') @@ -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() diff --git a/zdm/tests/test_cube.py b/zdm/tests/test_cube.py index 10da3bc1..eb5470f4 100644 --- a/zdm/tests/test_cube.py +++ b/zdm/tests/test_cube.py @@ -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 @@ -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 @@ -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() \ No newline at end of file +#test_cube_run() \ No newline at end of file