diff --git a/build/main b/build/main deleted file mode 100755 index 4093b44..0000000 Binary files a/build/main and /dev/null differ diff --git a/build/main.o b/build/main.o deleted file mode 100644 index d5059a5..0000000 Binary files a/build/main.o and /dev/null differ diff --git a/src/main.cu b/src/main.cu index 2d27d29..e360b0e 100644 --- a/src/main.cu +++ b/src/main.cu @@ -7,16 +7,22 @@ int main() { std::string path = "data/MERRA2_400.inst6_3d_ana_Np.20120101.nc4"; - std::string variable = "U"; + std::string variable = "T"; auto x = readData(path, variable); // Print some values from the file to see that it worked - int num = 0; + float sum = 0; + int n = 0; + int skipped = 0; for(int i = 0; i < x.size(); i++) { - if (x[i] < 1E14) std::cout << x[i] << "\n"; - if(num > 10000) break; - num++; + if (x[i] < 1E14) { + sum += x[i]; + n++; + } else { + skipped++; + } } + std::cout << "Mean = " << sum/n << " and sum = " << sum << " using " << n << " values in computation and skipped " << skipped << " values.\n"; return 0; } diff --git a/test_read.py b/test_read.py index bcee40c..8cfcc9c 100644 --- a/test_read.py +++ b/test_read.py @@ -15,9 +15,18 @@ print("Shape of U:", U.shape) # Compute the mean of the variable across all axes (for all elements in U) U_mean = np.mean(U) +U_sum = np.sum(U) # Print the mean print("Mean of U:", U_mean) +print("Sum of U:", U_sum) + +masked_count = np.ma.count_masked(U) +print("Number of masked values in U:", masked_count) + +nan_count = np.isnan(U).sum() +print("Number of NaN values in U:", nan_count) + # Close the NetCDF file ncfile.close()