mirror of
https://github.com/MartinOpat/cuda-based-raytrace.git
synced 2025-06-07 02:13:10 +02:00
FieldData structs implemented
This commit is contained in:
21
test_read.py
21
test_read.py
@@ -1,6 +1,5 @@
|
||||
import numpy as np
|
||||
from netCDF4 import Dataset
|
||||
from math import prod
|
||||
|
||||
# Load the NetCDF file
|
||||
file_path = 'data/MERRA2_400.inst6_3d_ana_Np.20120101.nc4'
|
||||
@@ -11,20 +10,24 @@ print(ncfile.variables.keys())
|
||||
|
||||
U = ncfile.variables['T'][:]
|
||||
|
||||
# Check the shape of the variable
|
||||
print(f"Shape of U: {U.shape} and total length is {prod(U.shape)}")
|
||||
# Check the shape of the variable
|
||||
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(f"{U[0,0,0,1]=}")
|
||||
is_masked = np.ma.isMaskedArray(U)
|
||||
print(f"Is U a masked array? {is_masked}")
|
||||
masked_count = np.ma.count_masked(U)
|
||||
print("Number of masked values in U:", masked_count)
|
||||
print("Sum of U:", U_sum)
|
||||
|
||||
sumval = 0
|
||||
row = U[0,0,100]
|
||||
for val in row:
|
||||
if not np.ma.is_masked(val):
|
||||
sumval += val
|
||||
print(f"Why does {np.sum(row)=} not equal {sumval=} ?!")
|
||||
|
||||
# Close the NetCDF file
|
||||
ncfile.close()
|
||||
ncfile.close()
|
||||
Reference in New Issue
Block a user