Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

I ATTACHED THE solar pdf the main task aND relevent data files i need the work on R markdown , and the output files in pdf word, html in Author name type Shamir Sheikh

1 answer below »
Assignment 1 Reading Rectangula
Tabular data
Not so simple!
STA141B Spring 2023
Professor Duncan Temple Lang
Due: April 17, 11pm
Submit via Canvas
The task is to read solar and climate-related data from a variety of locations in California. The data are related to sola
performance for buildings and simulation models for understanding this solar performance.
We have data for all of the USA and also for the entire world.
We will focus on just 5 locations and 5 ZIP files:
USA_CA_Fairfield-San.Francisco.Bay.Reserve.998011_TMYx XXXXXXXXXXzip
USA_CA_Marin.County.AP-Gnoss.Field.720406_TMYx XXXXXXXXXXzip
USA_CA_Napa.County.AP.724955_TMYx XXXXXXXXXXzip
USA_CA_Point.Reyes.Lighthouse.724959_TMYx XXXXXXXXXXzip
USA_CA_UC-Davis-University.AP.720576_TMYx XXXXXXXXXXzip
These are available in the Files section of the course’s Canvas portal.
In each ZIP archive, we have files with different file extensions such as clm, ddy, epw, stat, e.g.,
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.clm
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.ddy
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.epw
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.pvsyst
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.rain
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.stat
USA_CA_Bodega.Bay.CG.Light.Station.724995_TMYx.wea
There is a basic description of the formats of these different files in the ZIP archive. However, you will have to explore the
details of sample files to understand the general structure.
Tasks
For the 5 ZIP files provided, you are to read data from the
• .wea file
• .pvsyst file
• multiple rectangular tables in the .stat file.
Each of the .wea and .clm files co
espond to a single rectangular data set. However, the .stat file contains multiple rectangula
tables between other text.
Write functions (rather than one or more R commands) to read each of these tables, as you need to apply these to the contents
of the 5 ZIP files. Also, you will most likely need to run the code multiple times to iteratively modify it and verify it is co
ect.
Please use functions rather than repeating the same code for each file and table.
For the .stat file, read the tables fo
• Monthly Statistics for Dry Bulb temperatures
• Monthly Statistics for Dew Point temperatures
• Average Hourly Statistics for Dry Bulb temperatures
• Average Hourly Statistics for Dew Point temperatures
• Average Hourly Relative Humidity
• Monthly Wind Direction {Interval 11.25 deg from displayed deg)
• Average Hourly Statistics for Direct Normal Solar Radiation
• Monthly Statistics for Wind Speed
• Average Hourly Statistics for Wind Speed
For each of the monthly data sets:
1
https:
climate.onebuilding.org/WMO_Region_4_North_and_Central_America/USA_United_States_of_America/index.html
https:
climate.onebuilding.org/default.html
https:
climate.onebuilding.org/default.html
• Verify that the Max Hour and Min Hour are co
ect.
– then omit these rows
• Convert the data so that the rows co
esponding to measured variables and dates e.g. Maximum, Minimum, Daily Avg,
. . . are columns and the columns co
esponding to months are rows.
• Convert the Day:Hour values to a time (POSIXct). Use 2023 as the year.
• Convert the measurements for other variables to numbers.
For the hourly data tables,
• convert each to a data.frame with 3 columns:
– converting the month-hour pairs to rows with the single variable as a column
– one column for the month
– one column for the hour - 0, 1, 2, 23
Finally,
• combine the average hourly tables into a single data frame with a column for each variable, i.e., dry bulb temperature,
dew, relative radiation, wind speed. Ensure that the rows co
espond to the same time, i.e., month, hour and day.
• for each variable, plot the values against hour for each month.
Do this for the 5 zip files.
Try to find a common structure for the monthly and then the hourly, or for both, so that you can write code
to read these generally rather than code for each specific table.
Verifying Results
It is vital to verify that the results are co
ect. You need to check by
• manually comparing individual values in the files and the results,
• computing summary statistics from the results, and
• visualizing the results
• programmatically verifying the results,
to ensure they make sense and are co
ect.
Describe the approaches and processes by which you verified the results.
Identify Assumptions
State any assumptions you are making about the structure and order of the data, and show how you verified these were true.
Useful Functions
• strsplit()
• lapply(), sapply()
• list.files()
• readLines(), read.csv(), read.table()
• substring(), substr(),
• trimws()
• grep(), grepl(), gsub()
• which.min(), min(), max()
• data.frame(), as.data.frame()
• unlist()
• rep()
• strptime(), as.POSIXct(), as.Date()
• sprintf(), paste(), paste0()
• textConnection()
• close(), on.exit()
• %in%
• unzip()
• system(), system2()
•
ind(), do.call()
• by(), tapply(), aggregate()
The essential functions for checking results co
espond to what you expect include and debugging code include:
2
• length(), names(), dim(), nrow(), ncol(), class(), typeof(), is.na()
• debug()
•
owser()
• options(e
or = recover)
• summary(), plot()
3
    Assignment 1 Reading Rectangula
Tabular data
    Not so simple!
    STA141B Spring 2023
    Professor Duncan Temple Lang
    Due: April 17, 11pm
    Submit via Canvas
    Tasks
    Verifying Results
    Identify Assumptions
    Useful Functions
Answered 2 days After Apr 18, 2023

Solution

Banasree answered on Apr 21 2023
23 Votes
1. Read Data of .wea file.
Code1.
    # Set the path to the ZIP file
zip_file <- "usacafairfield-sanfranciscobayreserve998011tmyx2007-2021-qd4tltxj-uz2thcbz.zip"
# Extract the WEA file from the ZIP file
wea_file <- unzip(zip_file, list = TRUE)$Name[1] # assumes the WEA file is the first one in the ZIP file
unzip(zip_file, wea_file)
# Read the WEA file as a character vecto
wea_lines <- readLines(wea_file)
# Parse the WEA file into a data frame
wea_data <- do.call(
ind, lapply(wea_lines[-(1:2)], function(line) {
parts <- strsplit(line, "\\s+")[[1]]
data <- as.numeric(parts)
data <- data[!is.na(data)]
return(data)
}))
# Set the column names
colnames(wea_data) <- c("Year", "Month", "Day", "Hour", "Minute", "DHI", "DNI", "GHI", "DryBulbTemp", "DewPointTemp", "RelHumidity", "Pressure", "WindDir", "WindSpeed", "TotalSkyCover", "OpaqueSkyCover", "Visibility", "CeilingHeight", "PrecipitableWater")
# Print the first few rows of the data
head(wea_data)
Output:
Code 2
    # Set the path to the ZIP file
zip_file <- "usacamarincountyap-gnossfield720406tmyx2007-2021-40ryjwa5-er50ip1g.zip"
# Extract the WEA file from the ZIP file
wea_file <- unzip(zip_file, list = TRUE)$Name[1] # assumes the WEA file is the first one in the ZIP file
unzip(zip_file, wea_file)
# Read the WEA file as a character vecto
wea_lines <- readLines(wea_file)
# Parse the WEA file into a data frame
wea_data <- do.call(
ind, lapply(wea_lines[-(1:2)], function(line) {
parts <- strsplit(line, "\\s+")[[1]]
data <- as.numeric(parts)
data <- data[!is.na(data)]
return(data)
}))
# Set the column names
colnames(wea_data) <- c("Year", "Month", "Day", "Hour", "Minute", "DHI", "DNI", "GHI", "DryBulbTemp", "DewPointTemp", "RelHumidity", "Pressure", "WindDir", "WindSpeed", "TotalSkyCover", "OpaqueSkyCover", "Visibility", "CeilingHeight", "PrecipitableWater")
# Print the first few rows of the data
head(wea_data)
Output:
Code 3
    # Set the path to the ZIP file
zip_file <- "usacanapacountyap724955tmyx2007-2021-fio3d3mw-d0kt534v.zip"
# Extract the WEA file from the ZIP file
wea_file <- unzip(zip_file, list = TRUE)$Name[1] # assumes the WEA file is the first one in the ZIP file
unzip(zip_file, wea_file)
# Read the WEA file as a character vecto
wea_lines <-...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here