@@ -32,34 +32,49 @@ test_that("netCDF grid can be created",
3232 data(" catchments" )
3333
3434 # Extract catchment average monthly data P for Bet Bet Creek.
35- climateData = extractCatchmentData(ncdfFilename = ncdfFilename ,
35+ climateData.P = extractCatchmentData(ncdfFilename = ncdfFilename ,
3636 ncdfSolarFilename = ncdfSolarFilename ,
3737 extractFrom = startDate , extractTo = endDate ,
38- locations = catchments [ 1 ,] ,
38+ locations = catchments ,
3939 getTmin = F , getTmax = F , getVprp = F , getSolarrad = F , getET = F ,
4040 temporal.timestep = ' monthly' , temporal.function.name = ' sum' ,
4141 spatial.function.name = ' var' );
4242 },
4343 message = ' Testing extraction of P monthly data.'
4444 )
4545
46- # expect_no_error(
47- # {
48- # # Load the ET constants
49- # data(constants,package='Evapotranspiration')
50- #
51- # # Extract catchment average data for Bet Bet Creek with
52- # # the Mortons CRAE estimate of potential ET.
53- # climateData= extractCatchmentData(ncdfFilename=ncdfFilename,
54- # ncdfSolarFilename=ncdfSolarFilename,
55- # extractFrom=startDate, extractTo=endDate,
56- # locations=catchments[1,],
57- # temporal.timestep = 'monthly', temporal.function.name = 'sum',
58- # spatial.function.name='var',
59- # ET.function='ET.MortonCRAE',
60- # ET.timestep='monthly', ET.constants=constants);
61- # },
62- # message='Testing extraction of P monthly and PET data.'
63- # )
46+ expect_no_error(
47+ {
48+ # Load the ET constants
49+ data(constants ,package = ' Evapotranspiration' )
50+
51+ # Extract catchment average data for Bet Bet Creek with
52+ # the Mortons CRAE estimate of potential ET.
53+ climateData.P_PET = extractCatchmentData(ncdfFilename = ncdfFilename ,
54+ ncdfSolarFilename = ncdfSolarFilename ,
55+ extractFrom = startDate , extractTo = endDate ,
56+ locations = catchments ,
57+ temporal.timestep = ' monthly' , temporal.function.name = ' sum' ,
58+ spatial.function.name = ' var' ,
59+ ET.function = ' ET.MortonCRAE' ,
60+ ET.timestep = ' monthly' , ET.constants = constants );
61+ },
62+ message = ' Testing extraction of P monthly and PET data.'
63+ )
64+
65+ # Check outputs are data frames
66+ expect_type(climateData.P , ' list' )
67+ expect_type(climateData.P_PET , ' list' )
68+
69+ # Check dimensions of outputs
70+ expect_true(ncol(climateData.P $ catchmentTemporal.sum ) == 5 , ' Test expected number of columns in precip. data' )
71+ expect_true(ncol(climateData.P_PET $ catchmentTemporal.sum ) == 11 , ' Test expected number of columns in precip. and PET area weighted data' )
72+
73+ expect_true(nrow(climateData.P $ catchmentTemporal.sum ) == 4 , ' Test expected number of rows in precip. point data' )
74+ expect_true(nrow(climateData.P_PET $ catchmentTemporal.sum ) == 4 , ' Test expected number of rows in precip. and PET area weighted data' )
75+
76+ # check data is finite
77+ expect_true(all(is.finite(climateData.P $ catchmentTemporal.sum [,5 ])), ' Test precip results are finite' )
78+ expect_true(all(is.finite(climateData.P_PET $ catchmentTemporal.sum [,11 ])), ' Test PET results are finite' )
6479 }
6580)
0 commit comments