Created At: 2026-06-14T14:01:41Z
Completed At: 2026-06-14T14:01:41Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 4592
Total Bytes: 194080
Showing lines 58 to 168
The following code has been modified to include a line number before every line, in the format: <line_number>: <original_line>. Please note that any changes targeting the original code should remove the line number, colon, and leading space.
58: function ensure_sample_csv_exists_ipcc($location_sanitized, $variable_sanitized) {
59:     $dir = __DIR__ . "/data/{$location_sanitized}/{$variable_sanitized}";
60:     if (!is_dir($dir)) {
61:         mkdir($dir, 0777, true);
62:     }
63: 
64:     $base = 26.5; // default baseline (suhu)
65:     if (stripos($variable_sanitized, 'anomaly') !== false || stripos($variable_sanitized, 'anomali') !== false) {
66:         $base = 0.5; // default baseline (anomali suhu)
67:     } else if (stripos($variable_sanitized, 'precip') !== false || stripos($variable_sanitized, 'hujan') !== false) {
68:         $base = 2300; // default baseline (curah hujan)
69:     } else if (stripos($variable_sanitized, 'kelembaban') !== false || stripos($variable_sanitized, 'humidity') !== false) {
70:         $base = 82.0;
71:     } else if (stripos($variable_sanitized, 'kecepatan') !== false || stripos($variable_sanitized, 'angin') !== false || stripos($variable_sanitized, 'wind') !== false) {
72:         $base = 2.4;
73:     } else if (stripos($variable_sanitized, 'radiasi') !== false || stripos($variable_sanitized, 'matahari') !== false || stripos($variable_sanitized, 'solar') !== false) {
74:         $base = 178.0;
75:     }
76: 
77:     // 1. historical_timeseries.csv (1991 - 2020)
78:     $hist_path = "{$dir}/historical_timeseries.csv";
79:     if (!file_exists($hist_path)) {
80:         $handle = fopen($hist_path, "w");
81:         if ($handle !== FALSE) {
82:             fputcsv($handle, ['year', 'ssp126', 'ssp245', 'ssp370', 'ssp585']);
83:             for ($y = 1991; $y <= 2020; $y
<truncated 2875 bytes>
0.25) - $spread;
136:                     $ssp585 = ($base + ($idx * 0.052) + cos($y * 2.0) * 0.3) - $spread;
137:                 }
138:                 fputcsv($handle, [$y, round($ssp126, 2), round($ssp245, 2), round($ssp370, 2), round($ssp585, 2)]);
139:             }
140:             fclose($handle);
141:         }
142:     }
143: 
144:     // 4. areal_averaged_ensmax.csv (2021 - 2100)
145:     $max_path = "{$dir}/areal_averaged_ensmax.csv";
146:     if (!file_exists($max_path)) {
147:         $handle = fopen($max_path, "w");
148:         if ($handle !== FALSE) {
149:             fputcsv($handle, ['year', 'ssp126', 'ssp245', 'ssp370', 'ssp585']);
150:             for ($y = 2021; $y <= 2100; $y++) {
151:                 $idx = $y - 2021;
152:                 $spread = ($base > 1000) ? (200 + $idx * 3.5) : (0.25 + $idx * 0.006);
153:                 
154:                 if ($base > 1000) {
155:                     $ssp126 = ($base + ($idx * 0.4) + sin($y) * 90) + $spread;
156:                     $ssp245 = ($base + ($idx * 1.2) + cos($y) * 110) + $spread;
157:                     $ssp370 = ($base - ($idx * 1.6) + sin($y * 1.5) * 140) + $spread;
158:                     $ssp585 = ($base + ($idx * 4.2) + cos($y * 2.0) * 180) + $spread;
159:                 } else {
160:                     $ssp126 = ($base + ($idx * 0.006) + sin($y) * 0.15) + $spread;
161:                     $ssp245 = ($base + ($idx * 0.016) + cos($y) * 0.2) + $spread;
162:                     $ssp370 = ($base + ($idx * 0.036) + sin($y * 1.5) * 0.25) + $spread;
163:                     $ssp585 = ($base + ($idx * 0.052) + cos($y * 2.0) * 0.3) + $spread;
164:                 }
165:                 fputcsv($handle, [$y, round($ssp126, 2), round($ssp245, 2), round($ssp370, 2), round($ssp585, 2)]);
166:             }
167:             fclose($handle);
168:         }
The above content does NOT show the entire file contents. If you need to view any lines of the file which were not shown to complete your task, call this tool again to view those lines.
