433 + | Tests of sdbaseline rely on test_sdbaselinebasically, so we have minimal tests in imbaseline. |
434 + | |
435 + | 6-1. simple successful case |
436 + | 6-2. invalid ms stack |
437 + | 6-3. invalid image stack |
438 + | """ |
439 + | |
440 + | datapath = ctsys_resolve('unittest/imbaseline/') |
441 + | expected_im = "expected.im" |
442 + | expected_ms = "expected.ms" |
443 + | bloutput = "test.csv" |
444 + | maskmode = "auto" |
445 + | chans = "" |
446 + | thresh = 5.0 |
447 + | avg_limit = 4 |
448 + | minwidth = 4 |
449 + | edge = [0, 0] |
450 + | blfunc = "cspline" |
451 + | order = 5 |
452 + | npiece = 1 |
453 + | applyfft = True |
454 + | fftthresh = 3.0 |
455 + | addwn = [0] |
456 + | rejwn = [] |
457 + | blparam = '' |
458 + | clipniter = 10 |
459 + | clipthresh = 2.0 |
460 + | datacolumn = DATACOLUMN |
461 + | |
462 + | def setUp(self): |
463 + | self._copy_test_files(self.datapath, self.expected_im) |
464 + | self._copy_test_files(self.datapath, self.expected_ms) |
465 + | self.image_shape = get_image_shape(os.path.join(self.datapath, self.expected_im)) |
466 + | |
467 + | def test_6_1(self): |
468 + | image_stack = CasaImageStack(top=UnerasableFolder(self.expected_im)) |
469 + | ms_stack = MeasurementSetStack() |
470 + | ms_stack.push(EraseableFolder(self.expected_ms)) |
471 + | execute_sdbaseline(self.datacolumn, self.bloutput, self.maskmode, self.chans, self.thresh, self.avg_limit, self.minwidth, |
472 + | self.edge, self.blfunc, self.order, self.npiece, self.applyfft, self.fftthresh, self.addwn, self.rejwn, self.blparam, |
473 + | self.clipniter, self.clipthresh, image_stack, ms_stack, self.image_shape) |
474 + | self.assertTrue(os.path.exists(ms_stack.peak().path)) |
475 + | self.assertTrue(os.path.exists(self.bloutput)) |
476 + | self.assertTrue(os.path.exists(image_stack.peak().path)) |
477 + | |
478 + | @test_base.exception_case(RuntimeError, 'the stack is empty') |
479 + | def test_6_2(self): |
480 + | image_stack = CasaImageStack(top=UnerasableFolder(self.expected_im)) |
481 + | ms_stack = MeasurementSetStack() |
482 + | execute_sdbaseline(self.datacolumn, self.bloutput, self.maskmode, self.chans, self.thresh, self.avg_limit, self.minwidth, |
483 + | self.edge, self.blfunc, self.order, self.npiece, self.applyfft, self.fftthresh, self.addwn, self.rejwn, self.blparam, |
484 + | self.clipniter, self.clipthresh, image_stack, ms_stack, self.image_shape) |
485 + | |
486 + | @test_base.exception_case(RuntimeError, 'the stack has not have enough stuff') |
487 + | def test_6_3(self): |
488 + | image_stack = CasaImageStack() |
489 + | ms_stack = MeasurementSetStack() |
490 + | ms_stack.push(EraseableFolder(self.expected_ms)) |
491 + | execute_sdbaseline(self.datacolumn, self.bloutput, self.maskmode, self.chans, self.thresh, self.avg_limit, self.minwidth, |
492 + | self.edge, self.blfunc, self.order, self.npiece, self.applyfft, self.fftthresh, self.addwn, self.rejwn, self.blparam, |
493 + | self.clipniter, self.clipthresh, image_stack, ms_stack, self.image_shape) |
494 + | |
495 + | |
496 + | class image_subtraction_test(test_base): |
497 + | """Image subtraction test |
498 + | """ |
499 + | |
500 + | datapath = ctsys_resolve('unittest/imbaseline/') |
501 + | expected_im = "expected.im" |
502 + | expected_imsmoothed = "expected.imsmooth.im" |
503 + | expected_bl = "expected.bl.im" |
504 + | |
505 + | def setUp(self): |
506 + | self._copy_test_files(self.datapath, self.expected_im) |
507 + | self._copy_test_files(self.datapath, self.expected_imsmoothed) |
508 + | self._copy_test_files(self.datapath, self.expected_bl) |
509 + | |
510 + | def test_7_1(self): |
511 + | image_stack = CasaImageStack(top=UnerasableFolder(self.expected_im)) |
512 + | image_stack.push(EraseableFolder(self.expected_imsmoothed)) |
513 + | image_stack.push(EraseableFolder(self.expected_bl)) |
514 + | output = "output_7_1.im" |
515 + | execute_image_subtraction(output, image_stack) |
516 + | self.assertTrue(os.path.exists(output)) |
517 + | |
518 + | def test_7_2(self): |
519 + | image_stack = CasaImageStack(top=UnerasableFolder(self.expected_im)) |
520 + | image_stack.push(EraseableFolder(self.expected_bl)) |
521 + | output = "output_7_2.im" |
522 + | execute_image_subtraction(output, image_stack) |
523 + | self.assertTrue(os.path.exists(output)) |