Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MAIN.CPP
- #include <iostream>
- #include <fstream>
- #include <istream>
- #include <sstream>
- #include <string.h>
- #include <string>
- #include <map>
- #include "date.h"
- #include "VECTOR.h"
- #include "TIME.h"
- #include "FileWrite.h"
- using namespace std;
- Vector<string> SplitString(string source, string separator) {
- Vector<string> outValues;
- int lastPos = 0;
- for (;;) {
- int pos = source.find(separator, lastPos);
- if (pos == string::npos || pos == lastPos) { break; }
- string element = source.substr(lastPos, pos - lastPos);
- outValues.push_back(element);
- lastPos = pos + 1;
- }
- if (lastPos < source.length()) {
- outValues.push_back(source.substr(lastPos));
- }
- return outValues;
- }
- //////////////////////////////////////////////////
- /// Description: Data of the wind log
- //////////////////////////////////////////////////
- struct wind_log_data {
- Vector<int> day; /*!< vector of Day attribute */
- Vector<int> month; /*!< vector of Month attribute */
- Vector<int> year; /*!< vector of Year */
- Vector<float> w_speed; /*!< vector of Wind Speed attribute */
- Vector<float> a_a_temp; /*!< vector of Ambient Air Temperature attribute */
- Vector<float> s_radi; /*!< vector of Solar Radiation attribute */
- };
- wind_log_data row;
- int i_day = 0;
- int i_month = 0;
- int i_year = 0;
- float f_w_speed = 0.0;
- float f_a_a_temp = 0.0;
- float f_s_radi = 0.0;
- string line;
- int jan_length = 0;
- int feb_length = 0;
- int mar_length = 0;
- int apr_length = 0;
- int may_length = 0;
- int jun_length = 0;
- int jul_length = 0;
- int aug_length = 0;
- int sep_length = 0;
- int oct_length = 0;
- int nov_length = 0;
- int dec_length = 0;
- int vect_length;
- //////////////////////////////////////////////////
- /// Description: Data after calculating wind log
- //////////////////////////////////////////////////
- struct calculated_log {
- int month = 0; /*!< month of the total calculated wind log */
- int year = 0; /*!< year of the total calculated wind log */
- float total_w_speed = 0; /*!< total calculated wind speed */
- float total_a_a_temp = 0; /*!< total calculated ambient air temperature */
- float total_s_radi = 0; /*!< total calculated solar radiation */
- float avg_w_speed = 0; /*!< average calculated wind speed */
- float avg_a_a_temp = 0; /*!< average calculated ambient air temperature */
- } jan, feb, mar, apr, may, jun, jul, aug, sep, Oct, nov, Dec;
- struct year_log {
- calculated_log jan, feb, mar, apr, may, jun, jul, aug, sep, Oct, nov, Dec;
- } new_Year;
- map<int, year_log> map_year;
- calculated_log* logs[12];
- float calculateAvg(float total, int length) {
- if (length == 0) {
- return 0;
- }
- float avg_Result;
- avg_Result = total / length;
- return avg_Result;
- };
- float calculateKiloWatt(float watt10) {
- float kWh = watt10 / 6000;
- return kWh;
- }
- void totalLog() {
- for (int n = 0; n < vect_length; n++) {
- if (row.month.at(n) == 1) {
- if (jan.year == 0) {
- jan.year = row.year.at(n);
- }
- if (jan.month == 0) {
- jan.month = row.month.at(n);
- }
- jan.total_a_a_temp = jan.total_a_a_temp + row.a_a_temp.at(n);
- jan.total_s_radi = jan.total_s_radi + row.s_radi.at(n);
- jan.total_w_speed = jan.total_w_speed + row.w_speed.at(n);
- jan_length++;
- }
- else if (row.month.at(n) == 2) {
- if (feb.year == 0) {
- feb.year = row.year.at(n);
- }
- if (feb.month == 0) {
- feb.month = row.month.at(n);
- }
- feb.total_a_a_temp = feb.total_a_a_temp + row.a_a_temp.at(n);
- feb.total_s_radi = feb.total_s_radi + row.s_radi.at(n);
- feb.total_w_speed = feb.total_w_speed + row.w_speed.at(n);
- feb_length++;
- }
- else if (row.month.at(n) == 3) {
- if (mar.year == 0) {
- mar.year = row.year.at(n);
- }
- if (mar.month == 0) {
- mar.month = row.month.at(n);
- }
- mar.total_a_a_temp = mar.total_a_a_temp + row.a_a_temp.at(n);
- mar.total_s_radi = mar.total_s_radi + row.s_radi.at(n);
- mar.total_w_speed = mar.total_w_speed + row.w_speed.at(n);
- mar_length++;
- }
- else if (row.month.at(n) == 4) {
- if (apr.year == 0) {
- apr.year = row.year.at(n);
- }
- if (apr.month == 0) {
- apr.month = row.month.at(n);
- }
- apr.total_a_a_temp = apr.total_a_a_temp + row.a_a_temp.at(n);
- apr.total_s_radi = apr.total_s_radi + row.s_radi.at(n);
- apr.total_w_speed = apr.total_w_speed + row.w_speed.at(n);
- apr_length++;
- }
- else if (row.month.at(n) == 5) {
- if (may.year == 0) {
- may.year = row.year.at(n);
- }
- if (may.month == 0) {
- may.month = row.month.at(n);
- }
- may.total_a_a_temp = may.total_a_a_temp + row.a_a_temp.at(n);
- may.total_s_radi = may.total_s_radi + row.s_radi.at(n);
- may.total_w_speed = may.total_w_speed + row.w_speed.at(n);
- may_length++;
- }
- else if (row.month.at(n) == 6) {
- if (jun.year == 0) {
- jun.year = row.year.at(n);
- }
- if (jun.month == 0) {
- jun.month = row.month.at(n);
- }
- jun.total_a_a_temp = jun.total_a_a_temp + row.a_a_temp.at(n);
- jun.total_s_radi = jun.total_s_radi + row.s_radi.at(n);
- jun.total_w_speed = jun.total_w_speed + row.w_speed.at(n);
- jun_length++;
- }
- else if (row.month.at(n) == 7) {
- if (jul.year == 0) {
- jul.year = row.year.at(n);
- }
- if (jul.month == 0) {
- jul.month = row.month.at(n);
- }
- jul.total_a_a_temp = jul.total_a_a_temp + row.a_a_temp.at(n);
- jul.total_s_radi = jul.total_s_radi + row.s_radi.at(n);
- jul.total_w_speed = jul.total_w_speed + row.w_speed.at(n);
- jul_length++;
- }
- else if (row.month.at(n) == 8) {
- if (aug.year == 0) {
- aug.year = row.year.at(n);
- }
- if (aug.month == 0) {
- aug.month = row.month.at(n);
- }
- aug.total_a_a_temp = aug.total_a_a_temp + row.a_a_temp.at(n);
- aug.total_s_radi = aug.total_s_radi + row.s_radi.at(n);
- aug.total_w_speed = aug.total_w_speed + row.w_speed.at(n);
- aug_length++;
- }
- else if (row.month.at(n) == 9) {
- if (sep.year == 0) {
- sep.year = row.year.at(n);
- }
- if (sep.month == 0) {
- sep.month = row.month.at(n);
- }
- sep.total_a_a_temp = sep.total_a_a_temp + row.a_a_temp.at(n);
- sep.total_s_radi = sep.total_s_radi + row.s_radi.at(n);
- sep.total_w_speed = sep.total_w_speed + row.w_speed.at(n);
- sep_length++;
- }
- else if (row.month.at(n) == 10) {
- if (Oct.year == 0) {
- Oct.year = row.year.at(n);
- }
- if (Oct.month == 0) {
- Oct.month = row.month.at(n);
- }
- Oct.total_a_a_temp = Oct.total_a_a_temp + row.a_a_temp.at(n);
- Oct.total_s_radi = Oct.total_s_radi + row.s_radi.at(n);
- Oct.total_w_speed = Oct.total_w_speed + row.w_speed.at(n);
- oct_length++;
- }
- else if (row.month.at(n) == 11) {
- if (nov.year == 0) {
- nov.year = row.year.at(n);
- }
- if (nov.month == 0) {
- nov.month = row.month.at(n);
- }
- nov.total_a_a_temp = nov.total_a_a_temp + row.a_a_temp.at(n);
- nov.total_s_radi = nov.total_s_radi + row.s_radi.at(n);
- nov.total_w_speed = nov.total_w_speed + row.w_speed.at(n);
- nov_length++;
- }
- else if (row.month.at(n) == 12) {
- if (Dec.year == 0) {
- Dec.year = row.year.at(n);
- }
- if (Dec.month == 0) {
- Dec.month = row.month.at(n);
- }
- Dec.total_a_a_temp = Dec.total_a_a_temp + row.a_a_temp.at(n);
- Dec.total_s_radi = Dec.total_s_radi + row.s_radi.at(n);
- Dec.total_w_speed = Dec.total_w_speed + row.w_speed.at(n);
- dec_length++;
- }
- }
- }
- void readTheFile(ifstream& windfile, string line) {
- while (getline(windfile, line))
- {
- if (line == "WAST,DP,Dta,Dts,EV,EV10,RF,RF10,RH,S,SR,Sx,T" ||
- line == "WAST,DP,Dta,Dts,EV,EV10,RF,RF10,RH,S,SR,Sx,T\r") {
- continue;
- }
- if (line == "") { break; }
- Vector<string> pieces = SplitString(line, ",");
- Vector<string> DateTime = SplitString(pieces.at(0), " ");
- Vector<string> Date = SplitString(DateTime.at(0), "/");
- Vector<string> Time = SplitString(DateTime.at(1), ":");
- istringstream day(Date.at(0));
- day >> i_day;
- row.day.push_back(i_day);
- istringstream month(Date.at(1));
- month >> i_month;
- row.month.push_back(i_month);
- istringstream year(Date.at(2));
- year >> i_year;
- row.year.push_back(i_year);
- istringstream wSpeed(pieces.at(9));
- wSpeed >> f_w_speed;
- row.w_speed.push_back(f_w_speed);
- istringstream aaTemp(pieces.at(12));
- aaTemp >> f_a_a_temp;
- row.a_a_temp.push_back(f_a_a_temp);
- istringstream sRadi(pieces.at(10));
- sRadi >> f_s_radi;
- row.s_radi.push_back(f_a_a_temp);
- }
- }
- void totalAvg(struct calculated_log) {
- if (calculated_log().month == 1) {
- jan.avg_w_speed = calculateAvg(jan.total_w_speed, jan_length);
- }
- else if (calculated_log().month == 2) {
- feb.avg_w_speed = calculateAvg(feb.total_w_speed, feb_length);
- }
- else if (calculated_log().month == 3) {
- mar.avg_w_speed = calculateAvg(mar.total_w_speed, mar_length);
- }
- else if (calculated_log().month == 4) {
- apr.avg_w_speed = calculateAvg(apr.total_w_speed, apr_length);
- }
- else if (calculated_log().month == 5) {
- may.avg_w_speed = calculateAvg(may.total_w_speed, may_length);
- }
- else if (calculated_log().month == 6) {
- jun.avg_w_speed = calculateAvg(jun.total_w_speed, jun_length);
- }
- else if (calculated_log().month == 7) {
- jul.avg_w_speed = calculateAvg(jul.total_w_speed, jul_length);
- }
- else if (calculated_log().month == 8) {
- aug.avg_w_speed = calculateAvg(aug.total_w_speed, aug_length);
- }
- else if (calculated_log().month == 9) {
- sep.avg_w_speed = calculateAvg(sep.total_w_speed, sep_length);
- }
- else if (calculated_log().month == 10) {
- Oct.avg_w_speed = calculateAvg(Oct.total_w_speed, oct_length);
- }
- else if (calculated_log().month == 11) {
- nov.avg_w_speed = calculateAvg(nov.total_w_speed, nov_length);
- }
- else if (calculated_log().month == 12) {
- Dec.avg_w_speed = calculateAvg(Dec.total_w_speed, dec_length);
- }
- if (calculated_log().month == 1) {
- jan.avg_a_a_temp = calculateAvg(jan.total_a_a_temp, jan_length);
- }
- else if (calculated_log().month == 2) {
- feb.avg_a_a_temp = calculateAvg(feb.total_a_a_temp, feb_length);
- }
- else if (calculated_log().month == 3) {
- mar.avg_a_a_temp = calculateAvg(mar.total_a_a_temp, mar_length);
- }
- else if (calculated_log().month == 4) {
- apr.avg_a_a_temp = calculateAvg(apr.total_a_a_temp, apr_length);
- }
- else if (calculated_log().month == 5) {
- may.avg_a_a_temp = calculateAvg(may.total_a_a_temp, may_length);
- }
- else if (calculated_log().month == 6) {
- jun.avg_a_a_temp = calculateAvg(jun.total_a_a_temp, jun_length);
- }
- else if (calculated_log().month == 7) {
- jul.avg_a_a_temp = calculateAvg(jul.total_a_a_temp, jul_length);
- }
- else if (calculated_log().month == 8) {
- aug.avg_a_a_temp = calculateAvg(aug.total_a_a_temp, aug_length);
- }
- else if (calculated_log().month == 9) {
- sep.avg_a_a_temp = calculateAvg(sep.total_a_a_temp, sep_length);
- }
- else if (calculated_log().month == 10) {
- Oct.avg_a_a_temp = calculateAvg(Oct.total_a_a_temp, oct_length);
- }
- else if (calculated_log().month == 11) {
- nov.avg_a_a_temp = calculateAvg(nov.total_a_a_temp, nov_length);
- }
- else if (calculated_log().month == 12) {
- Dec.avg_a_a_temp = calculateAvg(Dec.total_a_a_temp, dec_length);
- }
- }
- void setMonthNull() {
- if (jan_length == 0) {
- jan.month = 1;
- }
- else if (feb_length == 0) {
- feb.month = 2;
- }
- else if (mar_length == 0) {
- mar.month = 3;
- }
- else if (apr_length == 0) {
- apr.month = 4;
- }
- else if (may_length == 0) {
- may.month = 5;
- }
- else if (jun_length == 0) {
- jun.month = 6;
- }
- else if (jul_length == 0) {
- jul.month = 7;
- }
- else if (aug_length == 0) {
- aug.month = 8;
- }
- else if (sep_length == 0) {
- sep.month = 9;
- }
- else if (oct_length == 0) {
- Oct.month = 10;
- }
- else if (nov_length == 0) {
- nov.month = 11;
- }
- else if (dec_length == 0) {
- Dec.month = 12;
- }
- }
- void clearData() {
- jan.month = 0;
- jan.year = 0;
- jan.total_w_speed = 0;
- jan.total_a_a_temp = 0;
- jan.total_s_radi = 0;
- jan.avg_w_speed = 0;
- jan.avg_a_a_temp = 0;
- feb.month = 0;
- feb.year = 0;
- feb.total_w_speed = 0;
- feb.total_a_a_temp = 0;
- feb.total_s_radi = 0;
- feb.avg_w_speed = 0;
- feb.avg_a_a_temp = 0;
- mar.month = 0;
- mar.year = 0;
- mar.total_w_speed = 0;
- mar.total_a_a_temp = 0;
- mar.total_s_radi = 0;
- mar.avg_w_speed = 0;
- mar.avg_a_a_temp = 0;
- apr.month = 0;
- apr.year = 0;
- apr.total_w_speed = 0;
- apr.total_a_a_temp = 0;
- apr.total_s_radi = 0;
- apr.avg_w_speed = 0;
- apr.avg_a_a_temp = 0;
- may.month = 0;
- may.year = 0;
- may.total_w_speed = 0;
- may.total_a_a_temp = 0;
- may.total_s_radi = 0;
- may.avg_w_speed = 0;
- may.avg_a_a_temp = 0;
- jun.month = 0;
- jun.year = 0;
- jun.total_w_speed = 0;
- jun.total_a_a_temp = 0;
- jun.total_s_radi = 0;
- jun.avg_w_speed = 0;
- jun.avg_a_a_temp = 0;
- jul.month = 0;
- jul.year = 0;
- jul.total_w_speed = 0;
- jul.total_a_a_temp = 0;
- jul.total_s_radi = 0;
- jul.avg_w_speed = 0;
- jul.avg_a_a_temp = 0;
- aug.month = 0;
- aug.year = 0;
- aug.total_w_speed = 0;
- aug.total_a_a_temp = 0;
- aug.total_s_radi = 0;
- aug.avg_w_speed = 0;
- aug.avg_a_a_temp = 0;
- sep.month = 0;
- sep.year = 0;
- sep.total_w_speed = 0;
- sep.total_a_a_temp = 0;
- sep.total_s_radi = 0;
- sep.avg_w_speed = 0;
- sep.avg_a_a_temp = 0;
- Oct.month = 0;
- Oct.year = 0;
- Oct.total_w_speed = 0;
- Oct.total_a_a_temp = 0;
- Oct.total_s_radi = 0;
- Oct.avg_w_speed = 0;
- Oct.avg_a_a_temp = 0;
- nov.month = 0;
- nov.year = 0;
- nov.total_w_speed = 0;
- nov.total_a_a_temp = 0;
- nov.total_s_radi = 0;
- nov.avg_w_speed = 0;
- nov.avg_a_a_temp = 0;
- Dec.month = 0;
- Dec.year = 0;
- Dec.total_w_speed = 0;
- Dec.total_a_a_temp = 0;
- Dec.total_s_radi = 0;
- Dec.avg_w_speed = 0;
- Dec.avg_a_a_temp = 0;
- }
- int main()
- {
- string fileName;
- int m_choice = 0;
- Time time;
- Date date;
- Vector<wind_log_data> windlog;
- ifstream fileDir;
- ifstream windfile;
- fileDir.open("met_index.txt", ios::in);
- if (!fileDir) return -1;
- while (getline(fileDir, fileName)) {
- windfile.open(fileName, ios::in);
- if (!windfile) return -1;
- readTheFile(windfile, line);
- vect_length = row.month.size();
- totalLog();
- logs[0] = &jan;
- logs[1] = &feb;
- logs[2] = &mar;
- logs[3] = &apr;
- logs[4] = &may;
- logs[5] = &jun;
- logs[6] = &jul;
- logs[7] = &aug;
- logs[8] = &sep;
- logs[9] = &Oct;
- logs[10] = &nov;
- logs[11] = &Dec;
- for (int i = 0; i < 12; i++) {
- totalAvg(*logs[i]);
- }
- setMonthNull();
- new_Year.jan = *logs[0];
- new_Year.feb = *logs[1];
- new_Year.mar = *logs[2];
- new_Year.apr = *logs[3];
- new_Year.may = *logs[4];
- new_Year.jun = *logs[5];
- new_Year.jul = *logs[6];
- new_Year.aug = *logs[7];
- new_Year.sep = *logs[8];
- new_Year.Oct = *logs[9];
- new_Year.nov = *logs[10];
- new_Year.Dec = *logs[11];
- map_year.insert(pair<int, year_log>(jan.year, new_Year));
- clearData();
- windfile.close();
- }
- std::cout << "1. The average wind speed and average ambient air temperature for a specified month and year. (print on screen only)" << '\n';
- std::cout << "2. Average wind speed and average ambient air temperature for each month of a specified year. (print on screen only)" << '\n';
- std::cout << "3. Total solar radiation in kWh/m2 for each month of a specified year. (print on screen only)" << '\n';
- std::cout << "4. Average wind speed (km/h), average ambient air tempature and total solar radiation in kWh/m2 for each month of a specified year. (print to a file called \"WindTempSolar.csv\")" << '\n';
- std::cout << "5. Exit the program." << '\n';
- std::cout << "Choose a menu: ";
- while (m_choice != 5) {
- cin >> m_choice;
- if (m_choice == 1) {
- std::cout << '\n';
- std::cout << "Choose a month (input the number of the month): ";
- cin >> i_month;
- std::cout << '\n';
- std::cout << "Choose a year: ";
- cin >> i_year;
- std::cout << '\n';
- std::cout << '\n';
- if (map_year.find(i_year) != map_year.end()) {
- if (i_month == 1) {
- if (i_year != map_year.at(i_year).jan.year) {
- cout << date.SetStringDate(map_year.at(i_year).jan.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).jan.month) << " " << i_year << ": ";
- if (map_year.at(i_year).jan.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).jan.avg_w_speed << " km/h, " << map_year.at(i_year).jan.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 2) {
- if (i_year != map_year.at(i_year).feb.year) {
- cout << date.SetStringDate(map_year.at(i_year).feb.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).feb.month) << " " << i_year << ": ";
- if (map_year.at(i_year).feb.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).feb.avg_w_speed << " km/h, " << map_year.at(i_year).feb.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 3) {
- if (i_year != map_year.at(i_year).mar.year) {
- cout << date.SetStringDate(map_year.at(i_year).mar.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).mar.month) << " " << i_year << ": ";
- if (map_year.at(i_year).mar.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).mar.avg_w_speed << " km/h, " << map_year.at(i_year).mar.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 4) {
- if (i_year != map_year.at(i_year).apr.year) {
- cout << date.SetStringDate(map_year.at(i_year).apr.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).apr.month) << " " << i_year << ": ";
- if (map_year.at(i_year).apr.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).apr.avg_w_speed << " km/h, " << map_year.at(i_year).apr.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 5) {
- if (i_year != map_year.at(i_year).may.year) {
- cout << date.SetStringDate(map_year.at(i_year).may.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).may.month) << " " << i_year << ": ";
- if (map_year.at(i_year).may.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).may.avg_w_speed << " km/h, " << map_year.at(i_year).may.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 6) {
- if (i_year != map_year.at(i_year).jun.year) {
- cout << date.SetStringDate(map_year.at(i_year).jun.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).jun.month) << " " << i_year << ": ";
- if (map_year.at(i_year).jun.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).jun.avg_w_speed << " km/h, " << map_year.at(i_year).jun.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 7) {
- if (i_year != map_year.at(i_year).jul.year) {
- cout << date.SetStringDate(map_year.at(i_year).jul.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).jul.month) << " " << i_year << ": ";
- if (map_year.at(i_year).jul.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).jul.avg_w_speed << " km/h, " << map_year.at(i_year).jul.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 8) {
- if (i_year != map_year.at(i_year).aug.year) {
- cout << date.SetStringDate(map_year.at(i_year).aug.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).aug.month) << " " << i_year << ": ";
- if (map_year.at(i_year).aug.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).aug.avg_w_speed << " km/h, " << map_year.at(i_year).aug.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 9) {
- if (i_year != map_year.at(i_year).sep.year) {
- cout << date.SetStringDate(map_year.at(i_year).sep.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).sep.month) << " " << i_year << ": ";
- if (map_year.at(i_year).sep.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).sep.avg_w_speed << " km/h, " << map_year.at(i_year).sep.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 10) {
- if (i_year != map_year.at(i_year).Oct.year) {
- cout << date.SetStringDate(map_year.at(i_year).Oct.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).Oct.month) << " " << i_year << ": ";
- if (map_year.at(i_year).Oct.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).Oct.avg_w_speed << " km/h, " << map_year.at(i_year).Oct.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 11) {
- if (i_year != map_year.at(i_year).nov.year) {
- cout << date.SetStringDate(map_year.at(i_year).nov.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).nov.month) << " " << i_year << ": ";
- if (map_year.at(i_year).nov.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).nov.avg_w_speed << " km/h, " << map_year.at(i_year).nov.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- else if (i_month == 12) {
- if (i_year != map_year.at(i_year).Dec.year) {
- cout << date.SetStringDate(map_year.at(i_year).Dec.month) << " " << i_year << ": " << "No Data" << '\n';
- }
- else {
- cout << date.SetStringDate(map_year.at(i_year).Dec.month) << " " << i_year << ": ";
- if (map_year.at(i_year).Dec.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).Dec.avg_w_speed << " km/h, " << map_year.at(i_year).Dec.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- }
- }
- else {
- cout << "No data found for this year given.";
- cout << '\n';
- }
- }
- else if (m_choice == 2) {
- std::cout << "Choose a year: ";
- cin >> i_year;
- std::cout << '\n';
- std::cout << '\n';
- cout << i_year << '\n';
- if (map_year.find(i_year) != map_year.end()) {
- cout << "January: ";
- if (i_year == map_year.at(i_year).jan.year) {
- if (map_year.at(i_year).jan.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).jan.avg_w_speed << " km/h, " << map_year.at(i_year).jan.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "Feburary: ";
- if (i_year == map_year.at(i_year).feb.year) {
- if (map_year.at(i_year).feb.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).feb.avg_w_speed << " km/h, " << map_year.at(i_year).feb.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "March: ";
- if (i_year == map_year.at(i_year).mar.year) {
- if (map_year.at(i_year).mar.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).mar.avg_w_speed << " km/h, " << map_year.at(i_year).mar.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "April: ";
- if (i_year == map_year.at(i_year).apr.year) {
- if (map_year.at(i_year).apr.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).apr.avg_w_speed << " km/h, " << map_year.at(i_year).apr.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "May: ";
- if (i_year == map_year.at(i_year).may.year) {
- if (map_year.at(i_year).may.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).may.avg_w_speed << " km/h, " << map_year.at(i_year).may.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "June: ";
- if (i_year == map_year.at(i_year).jun.year) {
- if (map_year.at(i_year).jun.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).jun.avg_w_speed << " km/h, " << map_year.at(i_year).jun.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "July: ";
- if (i_year == map_year.at(i_year).jul.year) {
- if (map_year.at(i_year).jul.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).jul.avg_w_speed << " km/h, " << map_year.at(i_year).jul.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "August: ";
- if (i_year == map_year.at(i_year).aug.year) {
- if (map_year.at(i_year).aug.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).aug.avg_w_speed << " km/h, " << map_year.at(i_year).aug.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "Sept: ";
- if (i_year == map_year.at(i_year).sep.year) {
- if (map_year.at(i_year).sep.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).sep.avg_w_speed << " km/h, " << map_year.at(i_year).sep.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "October: ";
- if (i_year == map_year.at(i_year).Oct.year) {
- if (map_year.at(i_year).Oct.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).Oct.avg_w_speed << " km/h, " << map_year.at(i_year).Oct.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "November: ";
- if (i_year == map_year.at(i_year).nov.year) {
- if (map_year.at(i_year).nov.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).nov.avg_w_speed << " km/h, " << map_year.at(i_year).nov.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "December: ";
- if (i_year == map_year.at(i_year).Dec.year) {
- if (map_year.at(i_year).Dec.avg_w_speed == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << map_year.at(i_year).Dec.avg_w_speed << " km/h, " << map_year.at(i_year).Dec.avg_a_a_temp << " degrees C" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- }
- else {
- cout << "No data for the selected year.";
- }
- }
- else if (m_choice == 3) {
- std::cout << "Choose a year: ";
- cin >> i_year;
- std::cout << '\n';
- std::cout << '\n';
- cout << i_year << '\n';
- if (map_year.find(i_year) != map_year.end()) {
- cout << "January: ";
- if (i_year == map_year.at(i_year).jan.year) {
- if (map_year.at(i_year).jan.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).jan.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "Feburary: ";
- if (i_year == map_year.at(i_year).feb.year) {
- if (map_year.at(i_year).feb.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).feb.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "March: ";
- if (i_year == map_year.at(i_year).mar.year) {
- if (map_year.at(i_year).mar.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).mar.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "April: ";
- if (i_year == map_year.at(i_year).apr.year) {
- if (map_year.at(i_year).apr.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).apr.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "May: ";
- if (i_year == map_year.at(i_year).may.year) {
- if (map_year.at(i_year).may.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).may.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "June: ";
- if (i_year == map_year.at(i_year).jun.year) {
- if (map_year.at(i_year).jun.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).jun.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "July: ";
- if (i_year == map_year.at(i_year).jul.year) {
- if (map_year.at(i_year).jul.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).jul.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "August: ";
- if (i_year == map_year.at(i_year).aug.year) {
- if (map_year.at(i_year).aug.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).aug.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "September: ";
- if (i_year == map_year.at(i_year).sep.year) {
- if (map_year.at(i_year).sep.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).sep.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "October: ";
- if (i_year == map_year.at(i_year).Oct.year) {
- if (map_year.at(i_year).Oct.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).Oct.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "November: ";
- if (i_year == map_year.at(i_year).nov.year) {
- if (map_year.at(i_year).nov.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).nov.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- cout << "December: ";
- if (i_year == map_year.at(i_year).Dec.year) {
- if (map_year.at(i_year).Dec.total_s_radi == 0) {
- cout << "No Data" << '\n';
- }
- else {
- cout << calculateKiloWatt(map_year.at(i_year).Dec.total_s_radi) << " kW/h2" << '\n';
- }
- }
- else {
- cout << "No Data" << '\n';
- }
- }
- else {
- cout << "No data found for selected year.";
- }
- }
- else if (m_choice == 4) {
- std::cout << '\n';
- std::cout << "Choose a year: ";
- cin >> i_year;
- std::cout << '\n';
- std::cout << '\n';
- std::string csvFile = "WindTempSolar.csv";
- FileWrite<string> dataFile;
- Vector<int> v_year;
- if (map_year.find(i_year) != map_year.end()) {
- v_year.push_back(i_year);
- if (!dataFile.fileExists(csvFile)) {
- dataFile.writeCsvFileInt(csvFile, v_year);
- }
- else {
- dataFile.cleanAndWriteCsvFileInt(csvFile, v_year);
- }
- for (int n = 0; n < 12; n++) {
- Vector<string> input_V;
- float c_total_s_radi;
- if (n == 0 && map_year.at(i_year).jan.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).jan.month));
- input_V.push_back(std::to_string(map_year.at(i_year).jan.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).jan.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).jan.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 1 && map_year.at(i_year).feb.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).feb.month));
- input_V.push_back(std::to_string(map_year.at(i_year).feb.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).feb.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).feb.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 2 && map_year.at(i_year).mar.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).mar.month));
- input_V.push_back(std::to_string(map_year.at(i_year).mar.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).mar.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).mar.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 3 && map_year.at(i_year).apr.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).apr.month));
- input_V.push_back(std::to_string(map_year.at(i_year).apr.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).apr.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).apr.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 4 && map_year.at(i_year).may.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).may.month));
- input_V.push_back(std::to_string(map_year.at(i_year).may.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).may.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).may.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 5 && map_year.at(i_year).jun.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).jun.month));
- input_V.push_back(std::to_string(map_year.at(i_year).jun.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).jun.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).jun.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 6 && map_year.at(i_year).jul.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).jul.month));
- input_V.push_back(std::to_string(map_year.at(i_year).jul.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).jul.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).jul.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 7 && map_year.at(i_year).aug.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).aug.month));
- input_V.push_back(std::to_string(map_year.at(i_year).aug.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).aug.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).aug.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 8 && map_year.at(i_year).sep.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).sep.month));
- input_V.push_back(std::to_string(map_year.at(i_year).sep.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).sep.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).sep.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 9 && map_year.at(i_year).Oct.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(Oct.month));
- input_V.push_back(std::to_string(map_year.at(i_year).Oct.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).Oct.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).Oct.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 10 && map_year.at(i_year).nov.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).nov.month));
- input_V.push_back(std::to_string(map_year.at(i_year).nov.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).nov.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).nov.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- else if (n == 11 && map_year.at(i_year).Dec.avg_w_speed != 0) {
- input_V.push_back(date.SetStringDate(map_year.at(i_year).Dec.month));
- input_V.push_back(std::to_string(map_year.at(i_year).Dec.avg_w_speed));
- input_V.push_back(std::to_string(map_year.at(i_year).Dec.avg_a_a_temp));
- c_total_s_radi = calculateKiloWatt(map_year.at(i_year).Dec.total_s_radi);
- string p_s_radi = (std::to_string(c_total_s_radi));
- input_V.push_back(p_s_radi);
- dataFile.writeCsvFile(csvFile, input_V);
- }
- }
- cout << "File written to WindTempSolar.csv" << '\n';
- }
- cout << "No data is found for the selected year.";
- }
- else if (m_choice == 5) {
- break;
- }
- else {
- std::cout << '\n';
- std::cout << "That is not a valid menu option." << '\n';
- std::cout << '\n';
- std::cout << "Please choose a menu from 1 to 5: ";
- }
- std::cout << "Choose a menu: ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement