-
Notifications
You must be signed in to change notification settings - Fork 20
Adding functionality to use ECMWF forecast or era5 grid instead of pre-processing grid + additional dustflag from Gareth #102
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
Open
dhegedus99
wants to merge
19
commits into
ORAC-CC:master
Choose a base branch
from
dhegedus99:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4a5a2c2
dustflag edits
dhegedus99 cfccd7a
get main processor to process new dust regions
dhegedus99 ce11cbd
Changes to indexing of preproc structures to use preproc_dims for all…
dhegedus99 8aa2bbd
Adding option to use native ECMWF grid for preprocessing
dhegedus99 97cd708
fixed issue with finidng minimum lat/lon when missing values (-999) a…
dhegedus99 1235aad
dustflag edits
dhegedus99 9d3d2bc
get main processor to process new dust regions
dhegedus99 e22a7e4
Changes to indexing of preproc structures to use preproc_dims for all…
dhegedus99 44f70b5
Adding option to use native ECMWF grid for preprocessing
dhegedus99 43c4770
fixed issue with finidng minimum lat/lon when missing values (-999) a…
dhegedus99 ef5e30c
Revert "Preproc grid"
dhegedus99 26af3e1
Merge branch 'preproc_grid_to_merge'
dhegedus99 d21d039
Remove whitespace and unnecessary print statements
dhegedus99 e76fe08
expand Pavolonis cloud class types in pyorac
dhegedus99 0161792
Merge remote-tracking branch 'source/master'
adamcpovey 48fc377
Whitespace tidying
adamcpovey ceec051
Update dependencies and more whitespace tidying
adamcpovey 944e9d7
Introduce INCLUDE_EMOS compilation option, making libEMOS optional.
adamcpovey fcd42a9
Merge pull request #8 from ORAC-CC/master
dhegedus99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,217 @@ | ||
| !------------------------------------------------------------------------------- | ||
| ! Name: morphology.F90 | ||
| ! | ||
| ! Purpose: | ||
| ! Module which provides simple morphological image transformation functions. | ||
| ! | ||
| ! Description and Algorithm details: | ||
| ! Four standard mathematical morphology functions are provided: | ||
| ! erode: "Shrinks" brighter (more positive) objects in an image, by an amount | ||
| ! defined by some kernel matrix (completely removing objects smaller | ||
| ! than the kernel) | ||
| ! dilate: "Grows" brighter objects by an amount defined by a kernel matrix. | ||
| ! open: Apply erode and dilate sequentially to the same image, using the same | ||
| ! kernel. This will have the effect of removing any bright features | ||
| ! smaller than the kernel - i.e. can be used to remove "salt-noise" or | ||
| ! spikes in a image. | ||
| ! close: The opposite of open. This has the effect of removing any dark | ||
| ! features smaller than the kernel - i.e. can be used to remove | ||
| ! "pepper-noise" or holes in an image. | ||
| ! All four functions accept two input arguments and return an integer matrix | ||
| ! with the same dimension as the first input array: | ||
| ! A(:,:) : The image to be transformed. Must be a 2-dimensional array (matrix) | ||
| ! of integers. Note that binary data will work (i.e. bolean | ||
| ! transformations will be done) but the output will still be integer | ||
| ! type. | ||
| ! B(:,:) : The transform kernel to apply. This should also be a 2-dimensional | ||
| ! integer array, smaller than A, with an odd number of elements in | ||
| ! both dimensions. | ||
| ! | ||
| ! Arguments: | ||
| ! None (see above) | ||
| ! | ||
| ! History: | ||
| ! 2024/03/08, GT: First version | ||
| ! | ||
| ! Bugs: | ||
| ! None known | ||
| !------------------------------------------------------------------------------- | ||
|
|
||
| module morphology_m | ||
|
dhegedus99 marked this conversation as resolved.
|
||
|
|
||
| implicit none | ||
|
|
||
| !!$ interface | ||
| !!$ function morph_erode(A, B) result(Ae) | ||
| !!$ ! Input variables | ||
| !!$ integer, dimension(:,:), intent(in) :: A | ||
| !!$ integer, dimension(:,:), intent(in) :: B | ||
| !!$ ! Returned variable | ||
| !!$ integer, dimension( size(A,1), size(A,2) ) :: Ae | ||
| !!$ end function morph_erode | ||
| !!$ function morph_dilate(A, B) result(Ad) | ||
| !!$ ! Input variables | ||
| !!$ integer, dimension(:,:), intent(in) :: A | ||
| !!$ integer, dimension(:,:), intent(in) :: B | ||
| !!$ ! Returned variable | ||
| !!$ integer, dimension( size(A,1), size(A,2) ) :: Ad | ||
| !!$ end function morph_dilate | ||
| !!$ function morph_open(A, B) result(Ao) | ||
| !!$ ! Input variables | ||
| !!$ integer, dimension(:,:), intent(in) :: A | ||
| !!$ integer, dimension(:,:), intent(in) :: B | ||
| !!$ ! Returned variable | ||
| !!$ integer, dimension( size(A,1), size(A,2) ) :: Ao | ||
| !!$ end function morph_open | ||
| !!$ function morph_close(A, B) result(Ac) | ||
| !!$ ! Input variables | ||
| !!$ integer, dimension(:,:), intent(in) :: A | ||
| !!$ integer, dimension(:,:), intent(in) :: B | ||
| !!$ ! Returned variable | ||
| !!$ integer, dimension( size(A,1), size(A,2) ) :: Ac | ||
| !!$ end function morph_close | ||
| !!$ end interface | ||
|
|
||
| contains | ||
|
|
||
| subroutine morph_check_range(x, dx, minx, maxx, xmdx, xpdx, o0, o1) | ||
|
|
||
| implicit none | ||
|
|
||
| ! Input variables | ||
| integer, intent(in) :: x, dx, minx, maxx | ||
| ! Output variables | ||
| integer, intent(out) :: xmdx, xpdx, o0, o1 | ||
|
|
||
| if (x-dx .lt. minx) then | ||
| xmdx = minx | ||
| o0 = 1 + minx - (x-dx) | ||
| else | ||
| xmdx = x-dx | ||
| o0 = 1 | ||
| end if | ||
| if (x+dx .gt. maxx) then | ||
| xpdx = maxx | ||
| o1 = 2*dx + 1 - (x+dx) + maxx | ||
| else | ||
| xpdx = x+dx | ||
| o1 = 2*dx + 1 | ||
| end if | ||
|
|
||
| end subroutine morph_check_range | ||
|
|
||
| function morph_erode(A, B) result(Ae) | ||
|
|
||
| implicit none | ||
|
|
||
| ! Input variables | ||
| integer, dimension(:,:), intent(in) :: A | ||
| integer, dimension(:,:), intent(in) :: B | ||
| ! Returned variable | ||
| integer, dimension( size(A,1), size(A,2) ) :: Ae | ||
| ! Local variables | ||
| ! Array dimensions | ||
| integer :: nx, ny, mx, my | ||
| ! Indices in x-direction | ||
| integer :: i, i0, i1, bi0, bi1 | ||
| ! Indices in y-direction | ||
| integer :: j, j0, j1, bj0, bj1 | ||
| ! Temporary array combining input and kernel | ||
| integer, dimension( size(B,1), size(B,2) ) :: Ab | ||
|
|
||
| ! Check that B has odd dimensions | ||
| if ((MOD(size(B,1), 2) .ne. 1) .or. (MOD(size(B,2), 2) .ne. 1)) then | ||
| write(*,*) 'ERROR: morph_erode(): Kernel array, B, must have odd dimensions' | ||
| stop 1 | ||
| end if | ||
|
|
||
| ! Define dimension variables | ||
| nx = size(A,1) | ||
| ny = size(A,2) | ||
| mx = size(B,1) / 2 | ||
| my = size(B,2) / 2 | ||
|
|
||
| ! Now step through the A array, applying the erode transform | ||
| do i = 1, nx | ||
| do j = 1, ny | ||
| call morph_check_range(i, mx, 1, nx, i0, i1, bi0, bi1) | ||
| call morph_check_range(j, my, 1, ny, j0, j1, bj0, bj1) | ||
| Ab(:,:) = 0 | ||
| Ab(bi0:bi1, bj0:bj1) = A(i0:i1, j0:j1) * B(bi0:bi1, bj0:bj1) | ||
| Ae(i, j) = minval(Ab, mask = B .gt. 0) | ||
| end do | ||
| end do | ||
|
|
||
| end function morph_erode | ||
|
|
||
| function morph_dilate(A, B) result(Ad) | ||
|
|
||
| implicit none | ||
| ! Input variables | ||
| integer, dimension(:,:), intent(in) :: A | ||
| integer, dimension(:,:), intent(in) :: B | ||
| ! Returned variable | ||
| integer, dimension( size(A,1), size(A,2) ) :: Ad | ||
| ! Local variables | ||
| ! Array dimensions | ||
| integer :: nx, ny, mx, my | ||
| ! Indices in x-direction | ||
| integer :: i, i0, i1, bi0, bi1 | ||
| ! Indices in y-direction | ||
| integer :: j, j0, j1, bj0, bj1 | ||
| ! Temporary array combining input and kernel | ||
| integer, dimension( size(B,1), size(B,2) ) :: Ab | ||
|
|
||
| ! Check that B has odd dimensions | ||
| if ((MOD(size(B,1), 2) .ne. 1) .or. (MOD(size(B,2), 2) .ne. 1)) then | ||
| write(*,*) 'ERROR: morph_dilate(): Kernel array, B, must have odd dimensions' | ||
| stop 1 | ||
| end if | ||
|
|
||
| ! Define dimension variables | ||
| nx = size(A,1) | ||
| ny = size(A,2) | ||
| mx = size(B,1) / 2 | ||
| my = size(B,2) / 2 | ||
|
|
||
| ! Now step through the A array, applying the dilate transform | ||
| do i = 1, nx | ||
| do j = 1, ny | ||
| call morph_check_range(i, mx, 1, nx, i0, i1, bi0, bi1) | ||
| call morph_check_range(j, my, 1, ny, j0, j1, bj0, bj1) | ||
| Ab(:,:) = 0 | ||
| Ab(bi0:bi1, bj0:bj1) = A(i0:i1, j0:j1) * B(bi0:bi1, bj0:bj1) | ||
| Ad(i, j) = maxval(Ab, mask = B .gt. 0) | ||
| end do | ||
| end do | ||
|
|
||
| end function morph_dilate | ||
|
|
||
| function morph_open(A, B) result(Ao) | ||
| implicit none | ||
| ! Input variables | ||
| integer, dimension(:,:), intent(in) :: A | ||
| integer, dimension(:,:), intent(in) :: B | ||
| ! Returned variable | ||
| integer, dimension( size(A,1), size(A,2) ) :: Ao | ||
|
|
||
| ! Simply call dilate on the erode of A, using the kernel B | ||
| Ao = morph_dilate( morph_erode(A, B), B) | ||
|
|
||
| end function morph_open | ||
|
|
||
| function morph_close(A, B) result(Ac) | ||
| implicit none | ||
| ! Input variables | ||
| integer, dimension(:,:), intent(in) :: A | ||
| integer, dimension(:,:), intent(in) :: B | ||
| ! Returned variable | ||
| integer, dimension( size(A,1), size(A,2) ) :: Ac | ||
|
|
||
| ! Simply call dilate on the erode of A, using the kernel B | ||
| Ac = morph_erode( morph_dilate(A, B), B) | ||
|
|
||
| end function morph_close | ||
|
|
||
|
|
||
| end module morphology_m | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why isn't this
prob_clear?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.
I think I took this from Gareth's original implementation of the dustflag, and didn't realise it corresponds to prob_clear - I can change it to "prob_clear"
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.
In the main ORAC repo it is also written as prob_opaque_ice. Should I change or resolve this conversation and merge?