Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4a5a2c2
dustflag edits
dhegedus99 Apr 25, 2024
cfccd7a
get main processor to process new dust regions
dhegedus99 Apr 30, 2024
ce11cbd
Changes to indexing of preproc structures to use preproc_dims for all…
dhegedus99 Jul 5, 2024
8aa2bbd
Adding option to use native ECMWF grid for preprocessing
dhegedus99 Jul 5, 2024
97cd708
fixed issue with finidng minimum lat/lon when missing values (-999) a…
dhegedus99 Oct 14, 2024
1235aad
dustflag edits
dhegedus99 Apr 25, 2024
9d3d2bc
get main processor to process new dust regions
dhegedus99 Apr 30, 2024
e22a7e4
Changes to indexing of preproc structures to use preproc_dims for all…
dhegedus99 Jul 5, 2024
44f70b5
Adding option to use native ECMWF grid for preprocessing
dhegedus99 Jul 5, 2024
43c4770
fixed issue with finidng minimum lat/lon when missing values (-999) a…
dhegedus99 Oct 14, 2024
ef5e30c
Revert "Preproc grid"
dhegedus99 Oct 14, 2024
26af3e1
Merge branch 'preproc_grid_to_merge'
dhegedus99 Oct 14, 2024
d21d039
Remove whitespace and unnecessary print statements
dhegedus99 Oct 15, 2024
e76fe08
expand Pavolonis cloud class types in pyorac
dhegedus99 Oct 15, 2024
0161792
Merge remote-tracking branch 'source/master'
adamcpovey Mar 21, 2025
48fc377
Whitespace tidying
adamcpovey Mar 21, 2025
ceec051
Update dependencies and more whitespace tidying
adamcpovey Mar 21, 2025
944e9d7
Introduce INCLUDE_EMOS compilation option, making libEMOS optional.
adamcpovey Mar 21, 2025
fcd42a9
Merge pull request #8 from ORAC-CC/master
dhegedus99 Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ COMMON_OBJ_F90 = $(OBJS)/chunk_utils.o \
$(OBJS)/common_constants.o \
$(OBJS)/constants_cloud_typing_pavolonis.o \
$(OBJS)/global_attributes.o \
$(OBJS)/morphology.o \
$(OBJS)/interpol.o \
$(OBJS)/hdf.o \
$(OBJS)/orac_indexing.o \
Expand Down
2 changes: 2 additions & 0 deletions common/constants_cloud_typing_pavolonis.F90
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ module constants_cloud_typing_pavolonis_m
integer(sint), parameter :: OVERLAP_TYPE = 8
integer(sint), parameter :: PROB_OPAQUE_ICE_TYPE = 9 ! missing ch3.7 due to low S/N
integer(sint), parameter :: PROB_CLEAR_TYPE = 10 ! cold antarctic
integer(sint), parameter :: DUST_CLEAR_TYPE = 11
integer(sint), parameter :: DUST_SWITCHED_FROM_CLOUD_TYPE = 12

!--- used for sunglint_mask, nise_mask
integer(sint), parameter :: NO = 0
Expand Down
9 changes: 7 additions & 2 deletions common/def_output_primary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
! 2018/01/19, GT: Removed QCFlag scale_factor and add_offset values, as these
! should only be used for packed floating point data.
! 2018/06/08, SP: Add satellite azimuth angle to output.
! 2024/03/13, GT: Updated cldtype to include dust values and removed
! scale_factor and add_offset from the various cloud mask/type variables
!
! Bugs:
! None known.
Expand Down Expand Up @@ -1823,7 +1825,10 @@ subroutine def_output_primary(ncid, dim3d_var, output_data, indexing, &
'opaque_ice ' // &
'cirrus ' // &
'overlap ' // &
'prob_opaque_ice'
'prob_opaque_ice ' // &
'N/A ' // &

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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"

Copy link
Copy Markdown
Contributor Author

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?

'dust_clear ' // &
'dust_switched_from_cloud'

call ncdf_def_var_byte_packed_byte( &
ncid, &
Expand All @@ -1839,7 +1844,7 @@ subroutine def_output_primary(ncid, dim3d_var, output_data, indexing, &
valid_min = output_data%cldtype_vmin, &
valid_max = output_data%cldtype_vmax, &
units = '1', &
flag_values = '0b 1b 2b 3b 4b 5b 6b 7b 8b 9b', &
flag_values = '0b 1b 2b 3b 4b 5b 6b 7b 8b 9b 10b 11b 12b', &
flag_meanings = trim(adjustl(input_dummy)), &
deflate_level = deflate_level, &
shuffle = shuffle_flag)
Expand Down
217 changes: 217 additions & 0 deletions common/morphology.F90
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
Comment thread
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
2 changes: 1 addition & 1 deletion common/orac_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ module orac_output_m
integer(byte) :: cldtype_scale = 1
integer(byte) :: cldtype_offset = 0
integer(byte) :: cldtype_vmin = 0
integer(byte) :: cldtype_vmax = 9
integer(byte) :: cldtype_vmax = 12

integer(byte) :: cldmask_scale = 1
integer(byte) :: cldmask_offset = 0
Expand Down
10 changes: 7 additions & 3 deletions config/lib.conda.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Set up libraries and includes
LIBS = -L$(CONDA_PREFIX)/lib \
-lemosR64 -lemos -lfftw3 \
-lfftw3 \
-lhdfeos -lGctp \
-leccodes_f90 -leccodes \
-lmfhdf -lmfhdf_fortran -lmfhdf_fcstub -lhdf \
Expand Down Expand Up @@ -38,6 +38,10 @@ CINC += -DINCLUDE_ATSR_SUPPORT
LIBS += -lnr
INC += -DINCLUDE_NR

# Uncomment if LIBEMOS is available for meteorological field interpolation.
#LIBS += -lemosR64 -lemos
#INC += -DINCLUDE_EMOS

# Uncomment if Fu_Liou support is desired for broadband fluxes.
LIBS += -lEd3Fu_201212
INC += -DINCLUDE_FU_LIOU_SUPPORT
Expand All @@ -52,5 +56,5 @@ INC += -DINCLUDE_SEVIRI_SUPPORT

# Uncomment if SEVIRI_ML support is desired.
# Please modify Python -lpython3.X to your Python version.
LIBS += -lsevann -lpython3.10
INC += -DINCLUDE_SEVIRI_NEURALNET
#LIBS += -lsevann -lpython3.10
#INC += -DINCLUDE_SEVIRI_NEURALNET
9 changes: 6 additions & 3 deletions config/lib.inc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SEVIRI_UTIL_LIB = $(LIBBASE_FORTRAN)/seviri_util
SEVIRI_UTIL_INCLUDE = $(LIBBASE_FORTRAN)/seviri_util

# seviri_ml
# run seviri_ml/get_py_config.sh to obtain your SEVIRI_ML_PYTHON_LIB
# run seviri_ml/get_py_config.sh to obtain your SEVIRI_ML_PYTHON_LIB
# and SEVIRI_ML_PYTHON_INCLUDE
SEVIRI_ML_LIB = $(LIBBASE_FORTRAN)/seviri_ml
SEVIRI_ML_INCLUDE = $(LIBBASE_FORTRAN)/seviri_ml
Expand All @@ -69,8 +69,7 @@ SEVIRI_ML_PYTHON_INCLUDE = /path/to/your/python/include
SZLIB = $(LIBBASE)/szip/lib

# Set up libraries and includes
LIBS = -L$(EMOSLIB) -lemosR64 -lemos -lfftw3 \
-L$(EOSLIB) -lhdfeos -lGctp \
LIBS = -L$(EOSLIB) -lhdfeos -lGctp \
-L$(GRIBLIB) -leccodes_f90 -leccodes \
-L$(HDFLIB) -lmfhdf -ldf \
-L$(NCDF_FORTRAN_LIB) -lnetcdff \
Expand Down Expand Up @@ -109,6 +108,10 @@ CINC = -I./
#LIBS += -L$(NRLIB) -lnr
#INC += -I$(NRINCLUDE) -DINCLUDE_NR

# Uncomment if LIBEMOS is available for meteorological field interpolation.
#LIBS += -L$(EMOSLIB) -lemosR64 -lemos -lfftw3
#INC += -DINCLUDE_EMOS

# Uncomment if Fu_Liou support is desired for broadband fluxes.
#LIBS += -L$(FULIOULIB) -lEd3Fu_201212
#INC += -I$(FULIOUINCLUDE) -DINCLUDE_FU_LIOU_SUPPORT
Expand Down
2 changes: 1 addition & 1 deletion derived_products/broadband_fluxes/dependencies.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $(OBJS)/two_rt_lw.o: $(OBJS)/kinds.o
$(OBJS)/two_rt_lw_iter.o: $(OBJS)/kinds.o
$(OBJS)/two_rt_lw_ocastrndm.o: $(OBJS)/kinds.o
$(OBJS)/two_rt_lw_sel.o: $(OBJS)/kinds.o
$(OBJS)/two_rt_sw_bs.o: $(OBJS)/kinds.o $(OBJS)/bandsolve.o
$(OBJS)/two_rt_sw_bs.o: $(OBJS)/bandsolve.o $(OBJS)/kinds.o
$(OBJS)/two_rt_sw.o: $(OBJS)/kinds.o
$(OBJS)/two_rt_sw_ocastrndm.o: $(OBJS)/kinds.o
$(OBJS)/comscp1.o: $(OBJS)/kinds.o
Expand Down
1 change: 1 addition & 0 deletions pre_processing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ PREPROC_OBJ_F90 = $(OBJS)/aatsr_corrections.o \
$(OBJS)/cloud_emis.o \
$(OBJS)/cloud_typing_pavolonis.o \
$(OBJS)/correct_for_ice_snow.o \
$(OBJS)/correct_for_dust.o \
$(OBJS)/cox_munk.o \
$(OBJS)/cox_munk_constants.o \
$(OBJS)/define_preprop_grid.o \
Expand Down
Loading