Astro-WaveBand

 view release on metacpan or  search on metacpan

t/waveband.t  view on Meta::CPAN

}

print "# ====== Test Alasdair's Modifications ======\n";

# static methods Astro::WaveBand

ok(Astro::WaveBand::has_filter(UIST => 'J98'),
    "UIST has J98");
ok(!Astro::WaveBand::has_filter(UIST => 'Kprime'),
    "UIST does not have Kprime");
ok(Astro::WaveBand::has_filter(UIST => 'J98', IRCAM => 'K98'),
    "UIST has J98 and IRCAM has K98");
ok(!Astro::WaveBand::has_filter(UIST => 'H98', IRCAM => 'K97'),
    "UIST = H98 and IRCAM=K97 fails");

ok(Astro::WaveBand::has_instrument(UKIRT => 'UIST'),
    "UKIRT has UIST");
ok(!Astro::WaveBand::has_instrument(UKIRT => 'SCUBA'),
    "UKIRT does not have SCUBA");

ok(Astro::WaveBand::is_observable(UKIRT => 'Kprime'),
    "UKIRT has Kprime");
ok(!Astro::WaveBand::is_observable(UKIRT => '850N'),
    "UKIRT does not have 850N");
ok(Astro::WaveBand::is_observable(JCMT => '850N'),
    "JCMT has 850N");

print "# ====== Test Brad's Modifications ======\n";

my $wb1 = Astro::WaveBand->new(Filter => 'K');
my $wb2 = Astro::WaveBand->new(Wavelength => '2.2');
my $wb3 = Astro::WaveBand->new(Filter => 'J');
ok($wb1->equals($wb2), "K is 2.2 microns");
ok($wb1 == $wb2, "K is 2.2 microns (using overloaded equality operator)");
ok($wb1 > $wb3, "K is longer wavelength than J (using overloaded greater than operator)");
ok($wb3 < $wb1, "J is shorter wavelength than K (using overloaded less than operator)");

# Check equality with same filter but different instrument.
my $wb_ufti = Astro::WaveBand->new(
    Filter => 'Z',
    Instrument => 'UFTI');
my $wb_wfcam = Astro::WaveBand->new(
    Filter => 'Z',
    Instrument => 'WFCAM');
ok($wb_ufti != $wb_wfcam, "UFTI Z is not equal to WFCAM Z");
ok(!($wb_ufti == $wb_wfcam), "UFTI Z is not equal to WFCAM Z");

my $wb4 = Astro::WaveBand->new(
    Instrument => 'HARP',
    Frequency => 345.7959899e9,
    Species => 'CO',
    Transition => '3 - 2');

isa_ok($wb4, 'Astro::WaveBand');
is($wb4->species, 'CO', 'Read species accessor');
is($wb4->transition, '3 - 2', 'Read transition accessor');
$wb4->frequency(354.5054759e9);
$wb4->species('HCN');
$wb4->transition('4 - 3');
is($wb4->species, 'HCN', 'Read update species accessor');
is($wb4->transition, '4 - 3', 'Read updated transition accessor');

is($wb4->frequency({format => 1}), '354.505 GHz', 'Format frequency');
is($wb4->frequency({format => 1, ndp => 1}), '354.5 GHz', 'Format frequency, 1 dp');
is($wb4->natural({format => 1, ndp => 2}), '354.51 GHz', 'Natural format, 2 dp');
is($wb4->wavelength({format => 1}), '845.664 mu', 'Format wavelength');
is($wb4->wavenumber({format => 1}), '11.825/cm', 'Format wavenumber');

exit;



( run in 0.887 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )