Commits
Muzychenko Inna authored 57cf45d7569
2154 2154 | (1) blparam contains values for all spectra |
2155 2155 | (2) no values for a spectrum (row=2,pol=1), which is to be skipped |
2156 2156 | (3) values commented out for a spectrum (row=2,pol=1), which is to be skipped |
2157 2157 | test303 : blmode='fit', bloutput!='', dosubtract=True, blfunc='poly','chebyshev','cspline' |
2158 2158 | testing if bltable is shortened |
2159 2159 | testing 3 cases: |
2160 2160 | (1) all spectra in row 2 are flagged entirely |
2161 2161 | (2) in row 2, entirely flagged for pol 0, also pol 1 is unselected |
2162 2162 | (3) in row 2, entirely flagged for pol 1, also pol 0 is unselected |
2163 2163 | test304 : same as test303, but for blfunc='variable' |
2164 - | test304 : blmode='fit', bloutput!='', dosubtract=True, blfunc='sinusoid' |
2164 + | test305 : blmode='fit', bloutput!='', dosubtract=True, blfunc='variable(sinusoid)' |
2165 2165 | |
2166 2166 | Note: input data is generated from a single dish regression data, |
2167 2167 | 'OrionS_rawACSmod', as follows: |
2168 2168 | sdcal(infile='OrionS_rawACSmod',scanlist=[20,21,22,23], |
2169 2169 | calmode='ps',tau=0.09,outfile='temp.asap') |
2170 2170 | sdcal(infile='temp.asap',timeaverage=True, |
2171 2171 | tweight='tintsys',outfile='temp2.asap') |
2172 2172 | sdsave(infile='temp2.asap',outformat='MS2', |
2173 2173 | outfile='OrionS_rawACSmod_calave.ms') |
2174 2174 | """ |
2675 2675 | List of tests necessary |
2676 2676 | 00: test baseline subtraction with variable baseline functions and orders |
2677 2677 | 01: test skipping rows by comment, i.e., lines start with '#' (rows should be flagged) |
2678 2678 | 02: test skipping rows by non-existent lines in blparam file (rows should be flagged) |
2679 2679 | 03: test mask selection |
2680 2680 | 04: test data selection |
2681 2681 | 05: test clipping |
2682 2682 | 06: duplicated fitting parameter in blparam file (the last one is adopted) |
2683 2683 | 10: check if baseline function names are correctly output in text file |
2684 2684 | 11: check if the numbers of baseline coefficients are correctly output in text/csv |
2685 + | 12: check if the numbers of sinusoid baseline coefficients are correctly output in csv |
2686 + | and length is same, some differences are acceptable due to ManyLinux nuance |
2685 2687 | NOT IMPLEMENTED YET |
2686 2688 | * line finder |
2687 2689 | * edge flagging |
2688 2690 | """ |
2689 2691 | outfile = 'variable_bl.ms' |
2690 2692 | column = 'float_data' |
2691 2693 | nspec = 4 |
2692 2694 | refstat0 = {'max': [0.0] * nspec, 'min': [0.0] * nspec, |
2693 2695 | 'rms': [0.0] * nspec, 'stddev': [0.0] * nspec} |
2694 2696 | |
2961 2963 | blformat=blformat, |
2962 2964 | bloutput=bloutput, |
2963 2965 | dosubtract=False, |
2964 2966 | blfunc='variable', |
2965 2967 | blparam=self.paramfile) |
2966 2968 | |
2967 2969 | with open(bloutput, 'r') as file: |
2968 2970 | list_all = [row for row in csv.reader(file)] |
2969 2971 | with open(output_reference, 'r') as ref_file: |
2970 2972 | ref_all = [row for row in csv.reader(ref_file)] |
2973 + | # Compare lengths of the lists |
2974 + | self.assertEqual(list_all, ref_all, |
2975 + | msg=f"Output lengths differ: ref={ref_all}, list={val_list}" ) |
2976 + | |
2971 2977 | for row_ref, row_list in zip(ref_all, list_all): |
2972 2978 | for idx, (val_ref, val_list) in enumerate(zip(row_ref, row_list)): |
2973 - | # Skip columns 5 and 6 (zero-based indexß) |
2974 - | if idx == 4 or idx == 5: |
2979 + | # Skip columns 5 and 6 (zero-based index) |
2980 + | if idx == 5 or idx == 6: |
2975 2981 | continue |
2976 2982 | |
2977 2983 | # Convert string values to floats for other columns |
2978 2984 | try: |
2979 2985 | float_val_ref = float(val_ref) |
2980 2986 | float_val_list = float(val_list) |
2981 2987 | except ValueError: |
2982 2988 | print("Warning: Skipping.. Cannot convert to float - {} {}" |
2983 2989 | .format(val_ref, val_list)) |
2984 2990 | continue |
2985 2991 | |
2986 - | # Compare float values using assertAlmostEqual |
2987 - | self.assertAlmostEqual(float_val_ref, float_val_list, |
2988 - | places=6, |
2989 - | msg=f"Values differ: ref={val_ref}, list={val_list}") |
2992 + | # Compare float values using assertAlmostEqual |
2993 + | self.assertAlmostEqual(float_val_ref, float_val_list, |
2994 + | places=6, |
2995 + | msg=f"Values differ: ref={val_ref}, list={val_list}") |
2990 2996 | finally: |
2991 2997 | remove_single_file_dir(output_reference) |
2992 2998 | |
2993 2999 | class sdbaseline_bloutputTest(sdbaseline_unittest_base): |
2994 3000 | """ |
2995 3001 | Basic unit tests for task sdbaseline. No interactive testing. |
2996 3002 | |
2997 3003 | List of tests: |
2998 3004 | |
2999 3005 | test000 : no bloutput cases |