def test_goes_chianti_tem_errors(): # Define input variables. ratio = SHORTFLUX / LONGFLUX shortflux_toomany = Quantity(np.append(SHORTFLUX.value, SHORTFLUX.value[0]), unit="W/m**2") shortflux_toosmall = copy.deepcopy(SHORTFLUX) shortflux_toosmall.value[0] = -1 shortflux_toobig = copy.deepcopy(SHORTFLUX) shortflux_toobig.value[0] = 1 temp_test = Quantity(np.zeros(len(LONGFLUX)) + 10, unit="MK") temp_test_toomany = Quantity(np.append(temp_test.value, 0), unit="MK") temp_test_toosmall = copy.deepcopy(temp_test) temp_test_toosmall.value[0] = -1 temp_test_toobig = copy.deepcopy(temp_test) temp_test_toobig.value[0] = 101 # First test correct exceptions are raised if incorrect inputs are # entered. with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, SHORTFLUX, satellite=-1) with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, shortflux_toomany) with pytest.raises(ValueError): temp = goes._goes_get_chianti_temp(ratio, satellite=-1) with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, SHORTFLUX, abundances="Neither") with pytest.raises(ValueError): temp = goes._goes_get_chianti_temp(ratio, abundances="Neither") with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, shortflux_toobig) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test, satellite=-1) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test, abundances="Neither") with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test, abundances="Neither") with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test_toosmall) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test_toobig)
def test_goes_chianti_tem_errors(): # Define input variables. ratio = SHORTFLUX/LONGFLUX shortflux_toomany = Quantity( np.append(SHORTFLUX.value, SHORTFLUX.value[0]), unit="W/m**2") shortflux_toosmall = copy.deepcopy(SHORTFLUX) shortflux_toosmall.value[0] = -1 shortflux_toobig = copy.deepcopy(SHORTFLUX) shortflux_toobig.value[0] = 1 temp_test = Quantity(np.zeros(len(LONGFLUX))+10, unit="MK") temp_test_toomany = Quantity(np.append(temp_test.value, 0), unit="MK") temp_test_toosmall = copy.deepcopy(temp_test) temp_test_toosmall.value[0] = -1 temp_test_toobig = copy.deepcopy(temp_test) temp_test_toobig.value[0] = 101 # First test correct exceptions are raised if incorrect inputs are # entered. with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, SHORTFLUX, satellite=-1) with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, shortflux_toomany) with pytest.raises(ValueError): temp = goes._goes_get_chianti_temp(ratio, satellite=-1) with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, SHORTFLUX, abundances="Neither") with pytest.raises(ValueError): temp = goes._goes_get_chianti_temp(ratio, abundances="Neither") with pytest.raises(ValueError): temp, em = goes._goes_chianti_tem(LONGFLUX, shortflux_toobig) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test, satellite=-1) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test, abundances="Neither") with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test, abundances="Neither") with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test_toosmall) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(LONGFLUX, temp_test_toobig)
def test_goes_chianti_tem(): longflux = np.array([7e-6]) shortflux = np.array([7e-7]) ratio = shortflux/longflux shortflux_toomany = np.append(shortflux, shortflux[0]) shortflux_toosmall = copy.deepcopy(shortflux) shortflux_toosmall[0] = -1 shortflux_toobig = copy.deepcopy(shortflux) shortflux_toobig[0] = 1 temp_test = np.zeros(len(longflux))+10 temp_test_toomany = np.append(temp_test, 0) temp_test_toosmall = copy.deepcopy(temp_test) temp_test_toosmall[0] = -1 temp_test_toobig = copy.deepcopy(temp_test) temp_test_toobig[0] = 101 date = "2014-04-16" # First test correct exceptions are raised if incorrect inputs are # entered. with pytest.raises(ValueError): temp, em = goes.goes_chianti_tem(longflux, shortflux, satellite=-1) with pytest.raises(ValueError): temp, em = goes.goes_chianti_tem(longflux, shortflux_toomany) with pytest.raises(ValueError): temp = goes._goes_get_chianti_temp(ratio, satellite=-1) with pytest.raises(ValueError): temp, em = goes.goes_chianti_tem(longflux, shortflux, abundances="Neither") with pytest.raises(ValueError): temp = goes._goes_get_chianti_temp(ratio, abundances="Neither") with pytest.raises(ValueError): temp, em = goes.goes_chianti_tem(longflux, shortflux_toobig) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(longflux, temp_test, satellite=-1) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(longflux, temp_test, abundances="Neither") with pytest.raises(ValueError): em = goes._goes_get_chianti_em(longflux, temp_test_toomany) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(longflux, temp_test_toosmall) with pytest.raises(ValueError): em = goes._goes_get_chianti_em(longflux, temp_test_toobig) # test case 1: satellite > 7, abundances = coronal temp1, em1 = goes.goes_chianti_tem(longflux, shortflux, satellite=15, date=date) assert np.around(temp1[0], decimals=2) == 11.28 assert em1[0] < 4.79e+48 and em1[0] > 4.78e+48 # test case 2: satellite > 7, abundances = photospheric temp2, em2 = goes.goes_chianti_tem(longflux, shortflux, satellite=15, date=date, abundances="photospheric") assert temp2[0] < 10.25 and temp2[0] > 10.24 assert em2[0] < 1.12e+49 and em2[0] > 1.11e+49 # test case 3: satellite < 8 and != 6, abundances = coronal temp3, em3 = goes.goes_chianti_tem(longflux, shortflux, satellite=5, date=date, abundances="coronal") assert temp3[0] < 11.43 and temp3[0] > 11.42 assert em3[0] < 3.85e+48 and em3[0] > 3.84e+48 # test case 4: satellite < 8 and != 6, abundances = photospheric temp4, em4 = goes.goes_chianti_tem(longflux, shortflux, satellite=5, date=date, abundances="photospheric") assert temp4[0] < 10.42 and temp4[0] > 10.41 assert em4[0] < 8.81e+48 and em4[0] > 8.80e+48 # test case 5: satellite = 6, date < 1983-06-28, abundances = coronal temp5, em5 = goes.goes_chianti_tem(longflux, shortflux, satellite=6, date="1983-06-27", abundances="coronal") assert temp5[0] < 12.30 and temp5[0] > 12.29 assert em5[0] < 3.13e+48 and em5[0] > 3.12e+48 # test case 6: satellite = 6, date < 1983-06-28, abundances = photospheric temp6, em6 = goes.goes_chianti_tem(longflux, shortflux, satellite=6, date="1983-06-27", abundances="photospheric") assert temp6[0] < 11.44 and temp6[0] > 11.43 assert em6[0] < 6.74e+48 and em6[0] > 6.73e+48 # test case 7: satellite = 6, date > 1983-06-28, abundances = coronal temp7, em7 = goes.goes_chianti_tem(longflux, shortflux, satellite=6, date=date, abundances="coronal") assert temp7[0] < 11.34 and temp7[0] > 11.33 assert em7[0] < 4.08e+48 and em7[0] > 4.07e+48 # test case 8: satellite = 6, date > 1983-06-28, abundances = photospheric temp8, em8 = goes.goes_chianti_tem(longflux, shortflux, satellite=6, date=date, abundances="photospheric") assert temp8[0] < 10.36 and temp8[0] > 10.35 assert em8[0] < 9.39e+48 and em8[0] > 9.38e+48