-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Improvement of testing routines #68
base: main
Are you sure you want to change the base?
Conversation
22c2ba9
to
95b1f77
Compare
95b1f77
to
80bd058
Compare
80bd058
to
1adf4ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AdelekeBankole This looks great, thank you!
We have just run these locally and everything is passing.
Just left a couple of comments for things to check or suggestions to make things a little clearer.
integer, parameter :: input_ver_dim = 30 | ||
!! The number of cells in a SAM atmospheric column on which the neural net was trained | ||
|
||
integer, parameter :: num_sam_cells = 30 | ||
!! number of SAM cells |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fulfill the same purpose - number of cells in a SAM column for which the net was trained, so we should look at combining them into one.
!! Define a CAM grid from 1111.0 to 10.0 | ||
!! Check interpolation to SAM grid by defining an idential CAM grid and | ||
!! interpolating a variable equal to the pressure | ||
!! Define a CAM grid consiting of 4 atmospheric columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! Define a CAM grid consiting of 4 atmospheric columns | |
!! Define a CAM grid consisting of 4 atmospheric columns |
real(dp), dimension(num_cols, nrf) :: p_cam, p_int_cam | ||
real(dp), dimension(num_cols, nrf) :: var_cam | ||
real(dp), dimension(num_cols) :: var_cam_surface | ||
real(dp), dimension(num_cols) :: ps_cam | ||
real(dp), dimension(num_cols, nrf) :: var_sam, var_sam_exp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These used to be length 48, but now use nrf which is length 30.
Should they be size sam_sounding
instead of nrf
?
p_cam = reshape((/ 1000.0, 1000.0, 1000.0, 1000.0, 500.0, 500.0, 500.0, 500.0, 10.0, 10.0, 10.0, 10.0 /), (/ 4, 3 /)) | ||
real(dp), dimension(num_cols, num_cells) :: p_cam | ||
real(dp), dimension(num_cols, num_cells) :: var_cam | ||
real(dp), dimension(num_cols) :: var_cam_surface | ||
real(dp), dimension(num_cols) :: ps_cam | ||
real(dp), dimension(num_cols, num_sam_cells) :: var_sam, var_sam_exp | ||
|
||
! Set up a coarse CAM grid of 4 columns of pressures [1000, 500, 10] hPa with surface pressure 1111 hPa | ||
do i = 1, num_cols | ||
p_cam(i, 1) = 1000.0 | ||
p_cam(i, 2) = 500.0 | ||
p_cam(i, 3) = 10.0 | ||
end do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much much better than the hardcoded and reshaped array!
!! Check interpolation to SAM grid by interpolating pressure to pressure | ||
!! Set top of CAM to 1.0d-4 | ||
!! => should match pres from SAM | ||
!! Use a coarse CAM grid of 3 cells and 4 columns | ||
!! => expected variable on SAM grid should be pressure at that point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should provide a bit more of an explanation as to what this test is checking.
e.g.
We are setting the variable equal to the coordinates (pressure) on the CAM grid, i.e. y=x.
We expect the interpolated values on the SAM grid to also satisfy y=x on that grid
rho_cam(:, i) = var_cam(:, i) / (p_int_cam(:, i)-p_int_cam(:, i+1)) | ||
subroutine test_interp_to_cam_coarse(test_name) | ||
!! Check conservative regridding to CAM coarse grid | ||
!! => should conserve density |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! => should conserve density | |
!! => should conserve mass |
Mass I think - as discussed.
! Fetch SAM grid data | ||
call fetch_sam_data(pres_sam, presi_sam, gamaz_sam, rho_sam, z_sam) | ||
|
||
! Define CAM grid coarser than SAM grid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
! Define CAM grid coarser than SAM grid | |
! Define CAM grid coarser than SAM grid - one CAM cell to every 3 SAM cells. |
do j = 1, num_cols | ||
! Set SAM variable (density) equal to 1.0 | ||
var_sam(j, :) = 1.0 | ||
end do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do j = 1, num_cols | |
! Set SAM variable (density) equal to 1.0 | |
var_sam(j, :) = 1.0 | |
end do | |
! Set SAM variable (density) equal to 1.0 | |
var_sam(:, :) = 1.0 |
|
||
subroutine test_interp_to_cam_coarse_variable_density(test_name) | ||
!! Check conservative regridding to CAM coarse grid with variable density | ||
!! => With integrated sum, this test should conserve density |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! => With integrated sum, this test should conserve density | |
!! => With integrated sum, this test should conserve mass |
do j = 1, num_cols | ||
do i = 1, num_sam_cells | ||
! Set SAM variable density not equal to 1.0 | ||
var_sam(j, i) = tan(real(i * j)) | ||
end do | ||
end do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good function to use, and also because it varies across columns, so will check that our scheme is robust in that sense as well! Great job.
This PR will close #64