The Subject/Language is UNIX Please answer the following steps with UNIX command
ID: 3705507 • Letter: T
Question
The Subject/Language is UNIX
Please answer the following steps with UNIX commands, thank you.
Consider the files files l2b1.iva, l2b2.iva, and l2b3.iva from your lab2B. These are raw performance data collected on a solar photovoltaic module installed at ASU Polytechnic campus. These data must be processed to determine the performance output of the system or panel. The 3 files correspond to 3 repeated measurements.
Upon processing, the test data are presented as shown in the table below:
Performance Data
Curve Name gge0001x gge0001y gge0001z
Date 12/30/2006 12/30/2006 12/30/2006
Time 14:15 14:15 14:16
Tamb (°C) 15.8 16.1 15.0
Tref (°C) 30.1 29.6 29.9
Tm (°C) 20.2 22.3 23.4
Irradiance (W/m^2) 1006.2 1003.5 999.8
Isc (A) 8.40 8.41 8.37
Voc (V) 37.14 36.82 36.62
Imp (A) 7.55 7.53 7.44
Vmp (V) 28.19 27.90 27.86
Pm (W) 212.86 210.15 207.15
FF (%) 68.3 67.9 67.6
In the table above, gge001x, gge001y, and gge001z are 3 repeated measurements on panel id gge001.
For this part of the lab, we’ll use the techniques learned in this Unit to edit and format the data to obtain a single file that looks like the above table (without the lines).
Write a shell script called lab5.2 for the processing, which includes the steps below:
Step 1: Use grep/fgrep/egrep and sed to process individual files
The output of each file should be reduced to 19 rows and 2 fields separated by a single space character, as shown below:
F gge0001x
D 12-30-2006
T 14:15:20
S a69
B 15.8
M gge06001
P 30.1
Q 20.2
R 1006.2
U 1011.8
X 34.7
A 38.994
G 107.71
H 8.395
O 37.141
C 7.55
K 28.193
W 212.86
L 68.3
To do so:
1. Delete the unnecessary rows. Do not use line numbers, because your program can be tested on files where line numbers might not match
2. On each line, replace tab and multiple space characters with a single character
3. Extract the first field and save to a file called lineid
4. Extract the second field of each file and save as the curve name. For example, the second field of the first file should be saved into file gge0001x. A possible breakdown of this process is as follow:
a. Use the sed’s back reference feature to delete the first identification field
b. Since the second field is now the first field, use the back reference feature to delete everything after the first field.
c. Save the output file as gge0001[xyz].
Step 2: Use the paste command to obtain a file called lab5.2.2 similar to the one below:
F gge0001x gge0001y gge0001z
D 12-30-2006 12-30-2006 12-30-2006
T 14:15:20 14:15:55 14:16:27
S a69 a69 a69
B 15.8 16.1 15
M gge06001 gge06001 gge06001
P 30.1 29.6 29.9
Q 20.2 22.3 23.4
R 1006.2 1003.5 999.8
U 1011.8 1011.8 1005
X 34.7 35.2 35.1
A 38.994 38.994 38.994
G 107.71 107.71 107.71
H 8.395 8.406 8.368
O 37.141 36.823 36.621
C 7.55 7.532 7.437
K 28.193 27.902 27.856
W 212.86 210.15 207.15
L 68.3 67.9 67.6
Step 3: Use the awk command and filtering features to create the final format of the file, as shown in “Performance Data” table. Call this file lab5.2.3
You’ll need to use the best possible ways (commands, pipelines, sequence) that result in an efficient processing (i.e. fewer keystrokes).
Explanation / Answer
CODING:
=========
#!/bin/bash
#set -x
echo "Performance Data"
IFS=$' '
for i in `cat data`;
do
field1=`echo $i | cut -d' ' -f1 field2=`echo $i | cut -d' ' -f2` field3=`echo $i | cut -d' ' -f3` field4=`echo $i | cut -d' ' -f4` if [[ $field1 = D ]];
then
echo -e "Date " $field2
fi
if [[ $field1 = B ]];
then
echo -e "Tamb(C) " $field2
fi
if [[ $field1 = P ]];
then
echo -e "Tref(C) " $field2
fi
if [[ $field1 = Q ]];
then
echo -e "Tm(C) " $field2
fi
if [[ $field1 = R ]];
then
echo -e "Irradiance(W/m^2) " $field2
fi
if [[ $field1 = H ]];
then
echo -e "Isc(A) " $field2
fi
if [[ $field1 = O ]];
then
echo -e "Voc(V) " $field2
fi
if [[ $field1 = C ]];
then
echo -e "Imp(A) " $field2
fi
if [[ $field1 = K ]];
then
echo -e "Vmp(V) " $field2
fi
if [[ $field1 = W ]];
then
echo -e "Pm(W) " $field2
fi
if [[ $field1 = L ]];
then
echo -e "FF(%) " $field2
fi
done
OUTPUT":
dheeraj@dheeraj-virtual Box:-$. /Script.sh
Performance Data
Date 12-30-2006
Tamb(c) 15.8
Tref(c) 30.1
Tm(c) 20.2
Irradiance(w/m^2) 1006.2
Isc(A) 8.395
Voc(v) 37.141
Imp(A) 7.55
Vmp(v) 28.193
Pm(W)) 212.86
FF(%) 68.3
dheeraj@dheeraj-Virtualbox:-$
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.