Reading an EPW file starts with function read_epw()
, which parses an EPW
file and returns an Epw
object. The parsing process is basically the same
as [EnergyPlus/WeatherManager.cc] in EnergyPlus, with some simplifications.
An EPW file can be divided into two parts, headers and weather data. The
first eight lines of a standard EPW file are normally headers which contains
data of location, design conditions, typical/extreme periods, ground
temperatures, holidays/daylight savings, data periods and other comments.
Epw
class provides methods to directly extract those data. For details on
the data structure of EPW file, please see "Chapter 2 - Weather Converter
Program" in EnergyPlus "Auxiliary Programs" documentation. An online version
can be found here.
There are about 35 variables in the core weather data. However, not all of them are used by EnergyPlus. Actually, despite of date and time columns, only 13 columns are used:
dry bulb temperature
dew point temperature
relative humidity
atmospheric pressure
horizontal infrared radiation intensity from sky
direct normal radiation
diffuse horizontal radiation
wind direction
wind speed
present weather observation
present weather codes
snow depth
liquid precipitation depth
Note the hour
column in the core weather data corresponds to the period
from (Hour-1)th to (Hour)th. For instance, if the number of interval
per hour is 1, hour of 1 on a certain day corresponds to the period between
00:00:01 to 01:00:00, Hour of 2 corresponds to the period between
01:00:01 to 02:00:00, and etc. Currently, in EnergyPlus the minute column is
not used to determine currently sub-hour time. For instance, if the
number of interval per hour is 2, there is no difference between two rows
with following time columns (a) Hour 1, Minute 0; Hour 1, Minute 30 and (b)
Hour 1, Minute 30; Hour 1, Minute 60. Only the number of rows count.
When EnergyPlus reads the EPW file, both (a) and (b) represent the same time
period: 00:00:00 - 00:30:00 and 00:30:00 - 01:00:00.
Missing data on the weather file used can be summarized in the eplusout.err
file, if DisplayWeatherMissingDataWarnings
is turned on in
Output:Diagnostics
object. In EnergyPlus, missing data is shown only for
fields that EnergyPlus will use. EnergyPlus will fill some missing data
automatically during simulation. Likewise out of range values are counted for
each occurrence and summarized. However, note that the out of range values
will not be changed by EnergyPlus and could affect your simulation.
Epw
class provides methods to easily extract and inspect those abnormal
(missing and out of range) weather data and also to know what kind of actions
that EnergyPlus will perform on those data.
EnergyPlus energy model calibration often uses actual measured weather data.
In order to streamline the error-prone process of creating custom EPW file,
Epw
provides methods to direction add, replace the core weather data.
new()
Create an Epw
object
Epw$new(path, encoding = "unknown")
path
Either a path, a connection, or literal data (either a
single string or a raw vector) to an EnergyPlus Weather File
(EPW). If a file path, that file usually has a extension
.epw
.
encoding
The file encoding of input IDD. Should be one of
"unknown"
, "Latin-1" and
"UTF-8". The default is
"unknown"` which means that the file is encoded in the native
encoding.
\dontrun{
# read an EPW file from EnergyPlus website
path_base <- "https://energyplus.net/weather-download"
path_region <- "north_and_central_america_wmo_region_4/USA/CA"
path_file <- "USA_CA_San.Francisco.Intl.AP.724940_TMY3/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
path_epw <- file.path(path_base, path_region, path_file)
epw <- read_epw(path_epw)
# read an EPW file distributed with EnergyPlus
if (is_avail_eplus(8.8)) {
path_epw <- file.path(
eplus_config(8.8)$dir,
"WeatherData",
"USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
)
epw <- read_epw(path_epw)
}
}
path()
Get the file path of current Epw
definition()
Get the IddObject object for specified EPW class.
$definition()
returns an IddObject of given EPW class. IddObject
contains all data used for parsing that EPW class.
Currently, all supported EPW classes are:
LOCATION
DESIGN CONDITIONS
TYPICAL/EXTREME PERIODS
GROUND TEMPERATURES
HOLIDAYS/DAYLIGHT SAVINGS
COMMENTS 1
COMMENTS 2
DATA PERIODS
WEATHER DATA
location()
Get and modify LOCATION header
Epw$location(
city,
state_province,
country,
data_source,
wmo_number,
latitude,
longitude,
time_zone,
elevation
)
city
A string of city name recorded in the LOCATION
header.
state_province
A string of state or province name recorded in
the LOCATION
header.
country
A string of country name recorded in the LOCATION
header.
data_source
A string of data source recorded in the LOCATION
header.
wmo_number
A string of WMO (World Meteorological Organization)
number recorded in the LOCATION
header.
latitude
A number of latitude recorded in the LOCATION
header. North latitude is positive and south latitude is
negative. Should in range [-90, +90]
.
longitude
A number of longitude recorded in the LOCATION
header. East longitude is positive and west longitude is
negative. Should in range [-180, +180]
.
time_zone
A number of time zone recorded in the LOCATION
header. Usually presented as the offset hours from UTC time.
Should in range [-12, +14]
.
elevation
A number of elevation recorded in the LOCATION
header. Should in range [-1000, 9999.9)
.
design_condition()
Get DESIGN CONDITION header
$design_condition()
returns the parsed values of DESIGN CONDITION
header in a list format with 4 elements:
source
: A string of source field
heating
: A list, usually of length 16, of the heading design conditions
cooling
: A list, usually of length 32, of the cooling design conditions
extremes
: A list, usually of length 16, of the extreme design conditions
For the meaning of each element, please see ASHRAE Handbook of Fundamentals.
typical_extreme_period()
Get TYPICAL/EXTREME header
$typical_extreme_period()
returns the parsed values of TYPICAL/EXTREME PERIOD
header in a data.table format with 6
columns:
index
: Integer type. The index of typical or extreme period record
name
: Character type. The name of typical or extreme period record
type
: Character type. The type of period. Possible value: typical
and
extreme
start_day
: Date type with customized formatting. The start day of the
period
start_day
: Date type with customized formatting. The end day of the
period
A data.table::data.table()
with 6 columns.
ground_temperature()
Get GROUND TEMPERATURE header
$ground_temperature()
returns the parsed values of GROUND TEMPERATURE
header in a data.table format with 17 columns:
index
: Integer type. The index of ground temperature record
depth
: Numeric type. The depth of the ground temperature is measured
soil_conductivity
: Numeric type. The soil conductivity at measured depth
soil_density
: Numeric type. The soil density at measured depth
soil_specific heat
: Numeric type. The soil specific heat at measured depth
January
to December
: Numeric type. The measured group
temperature for each month.
A data.table::data.table()
with 17 columns.
holiday()
Get and modify HOLIDAYS/DAYLIGHT SAVINGS header
leapyear
Either TRUE
or FALSE
.
dst
A length 2 EPW date specifications identifying the start
and end of daylight saving time. For example, c(3.10, 10.3)
.
holiday
a list or a data.frame containing two elements
(columns) name
and day
where name
are the holiday names
and day
are valid EPW date specifications. For example:
$holiday()
takes new value for leap year indicator, daylight saving time
and holiday specifications, set these new values and returns the parsed values
of HOLIDAYS/DAYLIGHT SAVINGS
header. If no input is given, current values
of HOLIDAYS/DAYLIGHT SAVINGS
header is returned. It returns a list of 3
elements:
leapyear
: A single logical vector. TRUE
means that the weather data
contains leap year data
dst
: A Date vector contains the start and end day of daylight saving time
holiday
: A data.table contains 2 columns. If
no holiday specified, an empty data.table
name
: Name of the holiday
day
: Date of the holiday
Validation process below is performed when changing the leapyear
indicator:
If current record of leapyear
is TRUE
, but new input is FALSE
, the
modification is only conducted when all data periods do not cover Feb 29.
If current record of leapyear
is FALSE
, but new input is TRUE
, the
modification is only conducted when TMY data periods do not across Feb,
e.g. [01/02, 02/28], [03/01, 12/31]; for AMY data, it is always OK.
The date specifications in dst
and holiday
should follow the rules of
"Table 2.14: Weather File Date File Interpretation" in
"AuxiliaryPrograms" documentation. eplusr is able to handle all those kinds of
formats automatically. Basically, 5 formats are allowed:
A single integer is interpreted as the Julian day of year. For example,
1
, 2
, 3
and 4
will be parsed and presented as 1st day
, 2nd day
, 3rd day
and 4th day
.
A single number is interpreted as Month.Day
. For example, 1.2
and 5.6
will be parsed and presented as Jan 02
and May 06
.
A string giving MonthName / DayNumber
, DayNumber / MonthName
, and
MonthNumber / DayNumber
. A year number can be also included. For
example, "Jan/1"
, "05/Dec"
, "7/8"
, "02/10/2019"
, and
"2019/04/05"
will be parsed and presented as Jan 02
, Dec 06
, Jul 8
, 2019-02-10
and 2019-04-15
.
A string giving number Weekday in Month
. For example, "2 Sunday in Jan"
will be parsed and presented as 2th Sunday in January
.
A string giving Last Weekday in Month
. For example, "last Sunday in Dec"
will be parsed and presented as Last Sunday in December
.
For convenience, besides all the formats described above, dst
and days in
holiday
also accept standard Dates input. They will be treated as the same
way as No.3 format described above.
comment1()
Get and modify COMMENT1 header
$comment1()
takes a single string of new comments and replaces the
old comment with input one. If NULL
is given, the comment is
removed. Empty string or a string that contains only spaces will be
treated as NULL
. If no input is given, current comment is returned.
If no comments exist, NULL
is returned.
comment2()
Get and modify COMMENT2 header
$comment2()
takes a single string of new comments and replaces the
old comment with input one. If NULL
is given, the comment is
removed. Empty string or a string that contains only spaces will be
treated as NULL
. If no input is given, current comment is returned.
If no comments exist, NULL
is returned.
num_period()
Get number of data periods in DATA PERIODS header
interval()
Get the time interval in DATA PERIODS header
period()
Get and modify data period meta data in DATA PERIODS header
period
A positive integer vector identifying the data period indexes.
name
A character vector used as new names for specified data
periods. Should have the same length as index
.
start_day_of_week
A character vector or an integer vector used
as the new start days of week of specified data periods.
Should have the same length as index
.
$period()
takes a data period index, a new period name and start
day of week specification, and uses that input to replace the data
period's name and start day of week. If no input is given, data
periods in current Epw
is returned.
A data.table with 5 columns:
index
: Integer type. The index of data period.
name
: Character type. The name of data period.
start_day_of_week
: Character type. The start day of week of data period.
start_day
: Date (EpwDate) type. The start day of data period.
end_day
: Date (EpwDate) type. The end day of data period.
missing_code()
Get missing code for weather data variables
initial_missing_value()
Get initial value for missing data of weather data variables
range_exist()
Get value ranges for existing values of weather data variables
range_valid()
Get value ranges for valid values of weather data variables
fill_action()
Get fill actions for abnormal values of weather data variables
Epw$fill_action(type = c("missing", "out_of_range"))
type
What abnormal type of actions to return. Should be one of
"missing"
and "out_of_range"
. Default: "missing"
.
$fill_action()
returns a list containing action
s that EnergyPlus
will perform when certain abnormal data found for corresponding
weather data. There are 3 types of actions in total:
do_nothing
: All abnormal values are left as they are.
use_zero
: All abnormal values are reset to zeros.
use_previous
: The first abnormal values of variables will be set to the
initial missing values. All after are set to previous valid one.
data()
Get weather data
Epw$data(
period = 1L,
start_year = NULL,
align_wday = TRUE,
tz = "UTC",
update = FALSE,
line = FALSE
)
period
A single positive integer identifying the data period
index. Data periods information can be obtained using
$period()
described above.
start_year
A positive integer identifying the year of first
date time in specified data period. If NULL
, the values in
the year
column are used as years of datetime
column.
Default: NULL
.
align_wday
Only applicable when start_year
is NULL
. If
TRUE
, a year value is automatically calculated for specified
data period that compliance with the start day of week value
specified in DATA PERIODS
header.
tz
A valid time zone to be assigned to the datetime
column.
All valid time zone names can be obtained using
OlsonNames()
. Default:"UTC"
.
update
If TRUE
, the year
column are updated according to
the newly created datetime
column using start_year
. If
FALSE
, original year data in the Epw
object is kept.
Default: FALSE
.
line
If TRUE
, a column named line
is prepended indicating
the line numbers where data occur in the actual EPW file.
Default: FALSE
.
$data()
returns weather data of specific data period.
Usually, EPW file downloaded from EnergyPlus website
contains TMY weather data. As years of weather data is not
consecutive, it may be more convenient to align the year values to be
consecutive, which will makes it possible to direct analyze and plot
weather data. The start_year
argument in $data()
method can help
to achieve this. However, randomly setting the year
may result in a
date time series that does not have the same start day of week as
specified in the DATA PERIODS
header. eplusr provides a simple
solution for this. By setting year
to NULL
and align_wday
to
TRUE
, eplusr will calculate a year value (from current year
backwards) for each data period that compliance with the start day of
week restriction.
Note that if current data period contains AMY data and start_year
is given, a warning is given because the actual year values will be
overwritten by input start_year
. An error is given if:
Using input start_year
introduces invalid date time. This may
happen when weather data contains leap year but input start_year
is not a leap year.
Applying specified time zone specified using tz
introduces
invalid date time.
A data.table::data.table()
of 36 columns.
\dontrun{
# get weather data
str(epw$data())
# get weather data but change the year to 2018
# the year column is not changed by default, only the returned datetime column
head(epw$data(start_year = 2018)$datetime)
str(epw$data(start_year = 2018)$year)
# you can update the year column too
head(epw$data(start_year = 2018, update = TRUE)$year)
# change the time zone of datetime column in the returned weather data
attributes(epw$data()$datetime)
attributes(epw$data(tz = "Etc/GMT+8")$datetime)
}
abnormal_data()
Get abnormal weather data
Epw$abnormal_data(
period = 1L,
cols = NULL,
keep_all = TRUE,
type = c("both", "missing", "out_of_range")
)
period
A single positive integer identifying the data period
index. Data periods information can be obtained using
$period()
described above.
cols
A character vector identifying what data columns, i.e.
all columns except datetime
, year
, month
, day
, hour
minute
, and character columns, to search abnormal values. If
NULL
, all data columns are used. Default: NULL
.
keep_all
If TRUE
, all columns are returned. If FALSE
, only
line
, datetime
, year
, month
, day
, hour
and
minute
, together with columns specified in cols
are
returned. Default: TRUE
type
What abnormal type of data to return. Should be one of
"all"
, "missing"
and "out_of_range"
. Default: "all"
.
$abnormal_data()
returns abnormal data of specific data period.
Basically, there are 2 types of abnormal data in Epw
, i.e. missing
values and out-of-range values. Sometimes, it may be useful to
extract and inspect those data especially when inserting measured
weather data. $abnormal_data()
does this.
In the returned data.table::data.table()
, a column named line
is created indicating the line numbers where abnormal data occur in
the actual EPW file.
\dontrun{
epw$abnormal_data()
# only check if there are any abnormal values in air temperature and
# liquid precipitation rate
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"))
# save as above, but only return date time columns plus those 2 columns
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"),
keep_all = FALSE
)
# same as above, but only check for missing values
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"),
type = "missing"
)
# same as above, but only check for out-of-range values
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"),
type = "out_of_range"
)
}
redundant_data()
Get redundant weather data
$redundant_data()
returns weather data in Epw
object that do not
belong to any data period. This data can be further removed using
$purge()
`
method described below.
In the returned data.table::data.table()
, a column named line
is created indicating the line numbers where redundant data occur in
the actual EPW file.
A data.table::data.table()
of 37 columns.
make_na()
Convert abnormal data into NAs
missing
If TRUE
, missing values are included. Default:
FALSE
.
out_of_range
If TRUE
, out-of-range values are included.
Default: FALSE
.
$make_na()
converts specified abnormal data into NA
s in specified
data period. This makes it easier to find abnormal data directly
using is.na()
instead of using
$missing_code()
$make_na()
and
$fill_abnormal()
are reversible, i.e.
$make_na()
can be used to counteract the effects introduced by
$make_na()
,
and vise a versa.
Note that $make_na
modify the weather data in-place, meaning
that the returned data from
$data()
and
$abnormal_data()
may be different after calling $make_na()
.
fill_abnormal()
Fill abnormal data using prescribed pattern
missing
If TRUE
, missing values are included. Default:
FALSE
.
out_of_range
If TRUE
, out-of-range values are included.
Default: FALSE
.
special
If TRUE
, abnormal data are filled using
corresponding actions listed
$fill_action()
.
If FALSE
, all abnormal data are fill with missing code
described in
$missing_code()
.
$fill_abnormal()
fills specified abnormal data using corresponding
actions listed in
$fill_action()
.
For what kinds of actions to be performed, please see
$fill_action()
.
method described above. Note that only if special
is TRUE
,
special actions listed in $fill_action()
is performed. If special
is FALSE
, all abnormal data, including both missing values and
out-of-range values, are filled with corresponding missing codes.
$make_na()
and $fill_abnormal()
are reversible, i.e.
$make_na()
can be used to counteract the effects introduced by
$fill_abnormal()
, and vise a versa.
Note that $fill_abnormal
modify the weather data in-place,
meaning that the returned data from
$data()
and
$abnormal_data()
may be different after calling $fill_abnormal()
.
add_unit()
Add units to weather data variables
$add_unit()
assigns units to numeric weather data using
units::set_units()
if applicable.
$add_unit()
and
$drop_unit()
are reversible, i.e.
$add_unit()
can be used to counteract the effects introduced by
$drop_unit()
,
and vise a versa.
Note that $add_unit
modify the weather data in-place,
meaning that the returned data from
$data()
and
$abnormal_data()
may be different after calling $add_unit()
.
drop_unit()
Remove units in weather data variables
$drop_unit()
removes all units of numeric weather data.
$add_unit()
and
$drop_unit()
are reversible, i.e.
$add_unit()
can be used to counteract the effects introduced by
$drop_unit()
,
and vise a versa.
Note that $add_unit
modify the weather data in-place,
meaning that the returned data from
$data()
and
$abnormal_data()
may be different after calling $add_unit()
.
add()
Add a data period
data
A data.table::data.table()
of new weather data to add
or set. Validation is performed according to rules described
above.
realyear
Whether input data is AMY data. Default: FALSE
.
name
A new string used as name of added or set data period.
Should not be the same as existing data period names. If
NULL
, it is generated automatically in format Data
,
Data_1
and etc., based on existing data period names.
Default: NULL
start_day_of_week
A single integer or character specifying
start day of week of input data period. If NULL
, Sunday is
used for TMY data and the actual start day of week is used for
AMY data. Default: NULL
.
after
A single integer identifying the index of data period
where input new data period to be inserted after. IF 0
,
input new data period will be the first data period. Default:
0
.
$add()
adds a new data period into current Epw
object at
specified position.
The validity of input data is checked before adding according to rules following:
Column datetime
exists and has type of POSIXct
. Note that time
zone of input date time will be reset to UTC
.
It assumes that input data is already sorted, i.e. no further
sorting is made during validation. This is because when input data
is TMY data, there is no way to properly sort input data rows only
using datetime
column.
Number of data records per hour should be consistent across input data.
Input number of data records per hour should be the same as existing data periods.
The date time of input data should not overlap with existing data periods.
Input data should have all 29 weather data columns with correct
types. The year
, month
, day
, and minute
column are not
compulsory. They will be created according to values in the
datetime
column. Existing values will be overwritten.
set()
Replace a data period
data
A data.table::data.table()
of new weather data to add
or set. Validation is performed according to rules described
above.
realyear
Whether input data is AMY data. Default: FALSE
.
name
A new string used as name of added or set data period.
Should not be the same as existing data period names. If
NULL
, it is generated automatically in format Data
,
Data_1
and etc., based on existing data period names.
Default: NULL
start_day_of_week
A single integer or character specifying
start day of week of input data period. If NULL
, Sunday is
used for TMY data and the actual start day of week is used for
AMY data. Default: NULL
.
period
A single integer identifying the index of data period to set.
$set()
replaces existing data period using input new weather data.
The validity of input data is checked before replacing according to rules following:
Column datetime
exists and has type of POSIXct
. Note that time
zone of input date time will be reset to UTC
.
It assumes that input data is already sorted, i.e. no further
sorting is made during validation. This is because when input data
is TMY data, there is no way to properly sort input data rows only
using datetime
column.
Number of data records per hour should be consistent across input data.
Input number of data records per hour should be the same as existing data periods.
The date time of input data should not overlap with existing data periods.
Input data should have all 29 weather data columns with right
types. The year
, month
, day
, and minute
column are not
compulsory. They will be created according to values in the
datetime
column. Existing values will be overwritten.
del()
Delete a data period
is_unsaved()
Check if there are unsaved changes in current Epw
save()
Save Epw
object as an EPW file
path
A path where to save the weather file. If NULL
, the
path of the weather file itself is used. Default: NULL
.
overwrite
Whether to overwrite the file if it already exists.
Default is FALSE
.
purge
Whether to remove redundant data when saving. Default:
FALSE
.
format_digit
Whether to remove trailing digits in weather
data. Default: TRUE
.
$save()
saves current Epw
to an EPW file. Note that if missing
values and out-of-range values are converted to NA
s using
$make_na()
,
they will be filled with corresponding missing codes during saving.
print()
Print Idf
object
## ------------------------------------------------
## Method `Epw$new`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# read an EPW file from EnergyPlus website
path_base <- "https://energyplus.net/weather-download"
path_region <- "north_and_central_america_wmo_region_4/USA/CA"
path_file <- "USA_CA_San.Francisco.Intl.AP.724940_TMY3/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
path_epw <- file.path(path_base, path_region, path_file)
epw <- read_epw(path_epw)
# read an EPW file distributed with EnergyPlus
if (is_avail_eplus(8.8)) {
path_epw <- file.path(
eplus_config(8.8)$dir,
"WeatherData",
"USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
)
epw <- read_epw(path_epw)
}
} # }
## ------------------------------------------------
## Method `Epw$path`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# get path
epw$path()
} # }
## ------------------------------------------------
## Method `Epw$definition`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# get path
epw$definition("LOCATION")
} # }
## ------------------------------------------------
## Method `Epw$location`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$location()
# modify location data
epw$location(city = "MyCity")
} # }
## ------------------------------------------------
## Method `Epw$design_condition`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$design_condition()
} # }
## ------------------------------------------------
## Method `Epw$typical_extreme_period`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$typical_extreme_period()
} # }
## ------------------------------------------------
## Method `Epw$ground_temperature`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$ground_temperature()
} # }
## ------------------------------------------------
## Method `Epw$holiday`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$holiday()
# add daylight saving time
epw$holiday(dst = c(3.10, 11.3))
} # }
## ------------------------------------------------
## Method `Epw$comment1`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$comment1()
epw$comment1("Comment1")
} # }
## ------------------------------------------------
## Method `Epw$comment2`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$comment2()
epw$comment2("Comment2")
} # }
## ------------------------------------------------
## Method `Epw$num_period`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$num_period()
} # }
## ------------------------------------------------
## Method `Epw$interval`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$interval()
} # }
## ------------------------------------------------
## Method `Epw$period`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# modify data period name
epw$period(1, name = "test")
# change start day of week
epw$period(1, start_day_of_week = 3)
} # }
## ------------------------------------------------
## Method `Epw$missing_code`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$missing_code()
} # }
## ------------------------------------------------
## Method `Epw$initial_missing_value`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$initial_missing_value()
} # }
## ------------------------------------------------
## Method `Epw$range_exist`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$range_exist()
} # }
## ------------------------------------------------
## Method `Epw$range_valid`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$range_valid()
} # }
## ------------------------------------------------
## Method `Epw$fill_action`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$fill_action("missing")
epw$fill_action("out_of_range")
} # }
## ------------------------------------------------
## Method `Epw$data`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# get weather data
str(epw$data())
# get weather data but change the year to 2018
# the year column is not changed by default, only the returned datetime column
head(epw$data(start_year = 2018)$datetime)
str(epw$data(start_year = 2018)$year)
# you can update the year column too
head(epw$data(start_year = 2018, update = TRUE)$year)
# change the time zone of datetime column in the returned weather data
attributes(epw$data()$datetime)
attributes(epw$data(tz = "Etc/GMT+8")$datetime)
} # }
## ------------------------------------------------
## Method `Epw$abnormal_data`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$abnormal_data()
# only check if there are any abnormal values in air temperature and
# liquid precipitation rate
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"))
# save as above, but only return date time columns plus those 2 columns
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"),
keep_all = FALSE
)
# same as above, but only check for missing values
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"),
type = "missing"
)
# same as above, but only check for out-of-range values
epw$abnormal_data(cols = c("dry_bulb_temperature", "liquid_precip_rate"),
type = "out_of_range"
)
} # }
## ------------------------------------------------
## Method `Epw$redundant_data`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$redundant_data()
} # }
## ------------------------------------------------
## Method `Epw$make_na`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# turn all missing values into NAs
summary(epw$data()$liquid_precip_rate)
epw$make_na(missing = TRUE)
summary(epw$data()$liquid_precip_rate)
} # }
## ------------------------------------------------
## Method `Epw$fill_abnormal`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# turn all missing values into NAs
summary(epw$data()$liquid_precip_rate)
epw$fill_abnormal(missing = TRUE)
summary(epw$data()$liquid_precip_rate)
} # }
## ------------------------------------------------
## Method `Epw$add_unit`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# get weather data with units
epw$add_unit()
head(epw$data())
# with units specified, you can easily perform unit conversion using units
# package
t_dry_bulb <- epw$data()$dry_bulb_temperature
units(t_dry_bulb) <- with(units::ud_units, "kelvin")
head(t_dry_bulb)
} # }
## ------------------------------------------------
## Method `Epw$drop_unit`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$drop_unit()
epw$data()
} # }
## ------------------------------------------------
## Method `Epw$purge`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$purge()
} # }
## ------------------------------------------------
## Method `Epw$add`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# will fail since date time in input data has already been covered by
# existing data period
try(epw$add(epw$data()), silent = TRUE)
} # }
## ------------------------------------------------
## Method `Epw$set`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# change the weather data
epw$set(epw$data())
} # }
## ------------------------------------------------
## Method `Epw$is_unsaved`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$is_unsaved()
} # }
## ------------------------------------------------
## Method `Epw$save`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# save the weather file
epw$save(file.path(tempdir(), "weather.epw"), overwrite = TRUE)
} # }
## ------------------------------------------------
## Method `Epw$print`
## ------------------------------------------------
if (FALSE) { # \dontrun{
epw$print()
} # }