invalid_values_file = joinpath(location, "data/all_baltic/invalid_obsval_shark.txt")
open(invalid_values_file, "w") do file
for value in invalid_obsval_shark
write(file, "$value\n")
end
end
Optionally, save the valid data back to the original variable or to a new file
@show sum(in_range)
@show sum(out_of_range)
The invalid values are now stored in invalid_obsval_shark.txt, and obsval_shark contains only the valid values
Add this to datahandling?
Define the range for valid values
min_value = 0.0 # Replace with your desired minimum value max_value = 100.0 # Replace with your desired maximum value
Perform the range check
in_range = obsval_shark .>= min_value .&& obsval_shark .<= max_value
Extract values within the range (valid data)
valid_obsval_shark = obsval_shark[in_range]
Extract values outside the range (invalid data)
out_of_range = .!in_range invalid_obsval_shark = obsval_shark[out_of_range]
Store the invalid values in a separate file
invalid_values_file = joinpath(location, "data/all_baltic/invalid_obsval_shark.txt") open(invalid_values_file, "w") do file for value in invalid_obsval_shark write(file, "$value\n") end end
Optionally, save the valid data back to the original variable or to a new file
@show sum(in_range) @show sum(out_of_range)
The invalid values are now stored in
invalid_obsval_shark.txt
, andobsval_shark
contains only the valid values