Skip to contents

Interpolate/re-express spectral irradiance (or other spectral quantity) values at new wavelengths values. This is a low-level function operating on numeric vectors and called by higher level functions in the package, such as mathematical operators for classes for spectral data.

Usage

interpolate_spectrum(w.length.in, s.irrad, w.length.out, fill = NA, ...)

Arguments

w.length.in

numeric vector of wavelengths (nm).

s.irrad

a numeric vector of spectral values.

w.length.out

numeric vector of wavelengths (nm).

fill

a value to be assigned to out of range wavelengths.

...

additional arguments passed to spline().

Value

a numeric vector of interpolated spectral values.

Note

The current version of interpolate uses spline if fewer than 25 data points are available. Otherwise it uses approx. In the first case a cubic spline is used, in the second case linear interpolation, which should be faster.

Examples


my.w.length <- 300:700
with(sun.data, interpolate_spectrum(w.length, s.e.irrad, my.w.length))
#>   [1] 0.001264554 0.002623718 0.003922583 0.008974134 0.011655666 0.017991275
#>   [7] 0.020761658 0.030591580 0.039978542 0.041639084 0.048712392 0.078527559
#>  [13] 0.080367380 0.094289456 0.105412629 0.112790138 0.102058726 0.148768985
#>  [19] 0.141391876 0.156969197 0.174169122 0.182203132 0.178721531 0.168053318
#>  [25] 0.207550771 0.216805488 0.277441571 0.285109584 0.264857263 0.299874513
#>  [31] 0.329518958 0.289551009 0.300071827 0.295150124 0.293696227 0.312925259
#>  [37] 0.271243302 0.260976992 0.290466940 0.310840376 0.335235319 0.305328678
#>  [43] 0.322195009 0.338005240 0.267587832 0.306027900 0.305130505 0.320791837
#>  [49] 0.305603819 0.298168712 0.345357201 0.341556702 0.323414777 0.330504697
#>  [55] 0.375862487 0.373763892 0.344165845 0.282222836 0.254490689 0.291694468
#>  [61] 0.370706830 0.307170911 0.324516952 0.360841632 0.368125255 0.366179060
#>  [67] 0.449189842 0.429468010 0.398062052 0.416799402 0.439323261 0.409285405
#>  [73] 0.378833546 0.357683807 0.326005743 0.338741381 0.394624218 0.418970286
#>  [79] 0.496971381 0.413149791 0.397674856 0.436211050 0.322994378 0.261431030
#>  [85] 0.300153524 0.391544645 0.354681256 0.374841506 0.365555284 0.396362059
#>  [91] 0.453539598 0.482210468 0.437234060 0.242202287 0.297644222 0.469988640
#>  [97] 0.405450284 0.254182717 0.503564422 0.586119023 0.608104877 0.626174220
#> [103] 0.649738778 0.620728707 0.637048946 0.626378620 0.599643955 0.595122643
#> [109] 0.625620917 0.661542103 0.560550458 0.650713476 0.674249832 0.645636462
#> [115] 0.663252803 0.647460864 0.676181832 0.644650255 0.633474327 0.644604654
#> [121] 0.598841551 0.670126933 0.666837734 0.611819108 0.602692194 0.606191811
#> [127] 0.638887302 0.595463601 0.592769703 0.547992196 0.457037071 0.413689966
#> [133] 0.646453175 0.652784601 0.629833249 0.662687445 0.733660742 0.726669733
#> [139] 0.645321225 0.602850221 0.643647639 0.673426029 0.718858063 0.705562936
#> [145] 0.706734749 0.696689331 0.665201654 0.737180964 0.769608965 0.744430705
#> [151] 0.775153602 0.820463342 0.769963708 0.697267409 0.732363421 0.765381427
#> [157] 0.774125663 0.798493545 0.761838948 0.769424580 0.769551282 0.771127687
#> [163] 0.761229358 0.760866657 0.760967158 0.745359011 0.758114649 0.742989105
#> [169] 0.766531175 0.766383174 0.748045520 0.742406604 0.769335685 0.751494433
#> [175] 0.745485216 0.772463397 0.768368987 0.764061376 0.786977343 0.753697541
#> [181] 0.771487291 0.763996666 0.783275921 0.773039789 0.749263417 0.733195569
#> [187] 0.652902130 0.651165424 0.716398516 0.702688375 0.772811081 0.735604670
#> [193] 0.689661134 0.738208076 0.733300961 0.789987227 0.760024838 0.753378017
#> [199] 0.712262795 0.725017333 0.724098235 0.709001697 0.691629553 0.730127374
#> [205] 0.725668867 0.737184608 0.770173714 0.736361219 0.701330220 0.746655664
#> [211] 0.742732159 0.738493353 0.751087598 0.712607287 0.700402655 0.693310040
#> [217] 0.730273261 0.617665218 0.644963708 0.637494891 0.698323787 0.715079946
#> [223] 0.730263301 0.695705698 0.736290334 0.737608845 0.692562308 0.649207176
#> [229] 0.721373613 0.731504253 0.730562857 0.760329660 0.724632351 0.646047102
#> [235] 0.672727894 0.708475517 0.742924836 0.715776953 0.736209227 0.722175087
#> [241] 0.675629939 0.668424621 0.709732364 0.717384896 0.724795825 0.727246427
#> [247] 0.699304126 0.711901259 0.693656490 0.702085310 0.704655110 0.703140897
#> [253] 0.717886336 0.692071644 0.707215385 0.711759892 0.699776245 0.687500598
#> [259] 0.691690903 0.676546347 0.682997060 0.697282697 0.667644497 0.699158988
#> [265] 0.689760552 0.691030049 0.650160315 0.669408771 0.675091491 0.650802622
#> [271] 0.651739716 0.644368480 0.657513818 0.671338953 0.665265926 0.653900084
#> [277] 0.659179593 0.664428699 0.657354465 0.647434024 0.664121163 0.670127970
#> [283] 0.685373604 0.683998192 0.679381371 0.672798245 0.652057679 0.655352889
#> [289] 0.630464328 0.565875951 0.570424859 0.606160550 0.598629221 0.610659840
#> [295] 0.616150651 0.602827712 0.617006037 0.625627153 0.623827236 0.624741526
#> [301] 0.637276746 0.629583712 0.630589004 0.636032911 0.657813967 0.661432277
#> [307] 0.655703462 0.649912648 0.654486861 0.649440349 0.639000522 0.639132824
#> [313] 0.646843646 0.635169215 0.628622299 0.630445405 0.610374752 0.600743827
#> [319] 0.636397425 0.642854444 0.637355531 0.646409857 0.634972528 0.627126608
#> [325] 0.611598268 0.609424964 0.600836444 0.606918172 0.589678938 0.603312874
#> [331] 0.599971460 0.598354254 0.584174618 0.604107069 0.599413654 0.608921081
#> [337] 0.600507257 0.611388086 0.623351017 0.613681790 0.599770051 0.604088763
#> [343] 0.613891791 0.612283890 0.600603360 0.592575244 0.577735916 0.561086580
#> [349] 0.554740369 0.556987470 0.566359186 0.579913525 0.568615701 0.581916331
#> [355] 0.578714123 0.561770580 0.498295902 0.516005449 0.568161191 0.576024010
#> [361] 0.578000613 0.596081660 0.599538267 0.596802361 0.591356846 0.590886447
#> [367] 0.589367045 0.585655836 0.597708872 0.596728172 0.592550463 0.589076157
#> [373] 0.581766939 0.584407549 0.587988463 0.585766359 0.585039960 0.583209758
#> [379] 0.580927455 0.579854155 0.576914450 0.572616242 0.572064144 0.569409041
#> [385] 0.568592243 0.565028736 0.532775954 0.474612718 0.475584826 0.473902623
#> [391] 0.489913869 0.502197202 0.502920107 0.487091273 0.472551439 0.477816556
#> [397] 0.490539390 0.516479856 0.505073328 0.483381678 0.475801560