Skip to content

Commit dd9b3d7

Browse files
authored
Merge pull request #868 from lsawade/stamp-fix
Stamp fix
2 parents 5161a4b + a34415e commit dd9b3d7

1 file changed

Lines changed: 54 additions & 48 deletions

File tree

src/auxiliaries/create_movie_GMT_global.f90

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -731,12 +731,12 @@ program create_movie_GMT_global
731731
if (zmesh > -SMALL_VAL_ANGLE .and. zmesh <= ZERO) zmesh = - real(SMALL_VAL_ANGLE,kind=CUSTOM_REAL)
732732
if (zmesh < SMALL_VAL_ANGLE .and. zmesh >= ZERO) zmesh = real(SMALL_VAL_ANGLE,kind=CUSTOM_REAL)
733733
thetaval = atan2(sqrt(xmesh*xmesh+ymesh*ymesh),zmesh)
734-
! thetaval between 0 and PI / 2
734+
! thetaval between 0 and PI
735735
!print *,'thetaval:',thetaval * 180. / PI
736-
! close to north pole
737-
if (thetaval >= 0.495 * PI ) istamp1 = ieoff
738-
! close to south pole
736+
! close to south pole (colatitude near 0, theta ~ 0-0.6 degrees)
739737
if (thetaval <= 0.01 ) istamp2 = ieoff
738+
! close to north pole (colatitude near 180, theta ~ 179.1-180 degrees)
739+
if (thetaval >= 0.99 * PI ) istamp1 = ieoff
740740
endif
741741

742742
enddo !i
@@ -810,35 +810,36 @@ program create_movie_GMT_global
810810
! this should avoid flickering when normalizing wavefields
811811
if (AVERAGE_NORMALIZE_VALUES) then
812812
! checks stamp indices for maximum values
813-
if (istamp1 == 0 ) istamp1 = ieoff
814-
if (istamp2 == 0 ) istamp2 = ieoff-1
815-
!print *, 'stamp: ',istamp1,istamp2
816-
817-
if (max_absol < max_average) then
818-
! distance (in degree) of surface waves travelled
819-
distance = real(SURFACE_WAVE_VELOCITY * ((it-1)*DT-t0) / (R_PLANET/1000.d0) * RADIANS_TO_DEGREES,kind=CUSTOM_REAL)
820-
if (distance > 10.0 .and. distance <= 20.0) then
821-
! smooth transition between 10 and 20 degrees
822-
! sets positive and negative maximum
823-
field_display(istamp1) = + max_absol + (max_average-max_absol) * (distance - 10.d0)/10.d0
824-
field_display(istamp2) = - ( max_absol + (max_average-max_absol) * (distance - 10.d0)/10.d0 )
825-
else if (distance > 20.0) then
813+
! only apply stamping if both poles were found
814+
if (istamp1 > 0 .and. istamp2 > 0) then
815+
!print *, 'stamp: ',istamp1,istamp2
816+
817+
if (max_absol < max_average) then
818+
! distance (in degree) of surface waves travelled
819+
distance = real(SURFACE_WAVE_VELOCITY * ((it-1)*DT-t0) / (R_PLANET/1000.d0) * RADIANS_TO_DEGREES,kind=CUSTOM_REAL)
820+
if (distance > 10.0 .and. distance <= 20.0) then
821+
! smooth transition between 10 and 20 degrees
822+
! sets positive and negative maximum
823+
field_display(istamp1) = + max_absol + (max_average-max_absol) * (distance - 10.d0)/10.d0
824+
field_display(istamp2) = - ( max_absol + (max_average-max_absol) * (distance - 10.d0)/10.d0 )
825+
else if (distance > 20.0) then
826+
! sets positive and negative maximum
827+
field_display(istamp1) = + max_average
828+
field_display(istamp2) = - max_average
829+
endif
830+
else
831+
! thresholds positive & negative maximum values
832+
where( field_display(:) > max_average ) field_display = max_average
833+
where( field_display(:) < - max_average ) field_display = -max_average
826834
! sets positive and negative maximum
827835
field_display(istamp1) = + max_average
828836
field_display(istamp2) = - max_average
829837
endif
830-
else
831-
! thresholds positive & negative maximum values
832-
where( field_display(:) > max_average ) field_display = max_average
833-
where( field_display(:) < - max_average ) field_display = -max_average
834-
! sets positive and negative maximum
835-
field_display(istamp1) = + max_average
836-
field_display(istamp2) = - max_average
837-
endif
838-
! updates current wavefield maxima
839-
min_field_current = minval(field_display(:))
840-
max_field_current = maxval(field_display(:))
841-
max_absol = (abs(min_field_current)+abs(max_field_current))/2.d0
838+
! updates current wavefield maxima
839+
min_field_current = minval(field_display(:))
840+
max_field_current = maxval(field_display(:))
841+
max_absol = (abs(min_field_current)+abs(max_field_current))/2.d0
842+
endif ! istamp1 > 0 .and. istamp2 > 0
842843
endif
843844

844845
! scales field values up to match average
@@ -860,30 +861,35 @@ program create_movie_GMT_global
860861
else
861862
! no wavefield yet assumed
862863

863-
! we set two single field values (last in array)
864-
! to: +/- 100 * max_average
864+
! we set two single field values (at poles if found)
865+
! to: +/- 100 * max_average (or scaled value)
865866
! to avoid further amplifying when
866867
! a normalization routine is used for rendering images
867868
! (which for example is the case for shakemovies)
868-
if (STARTTIME_TO_MUTE > TINYVAL) then
869-
! with additional scale factor:
870-
! linear scaling between [0,1]:
871-
! from 0 (simulation time equal to -t0 )
872-
! to 1 (simulation time equals starttime_to_mute)
873-
mute_factor = real(1.d0 - ( STARTTIME_TO_MUTE - ((it-1)*DT-t0) ) / (STARTTIME_TO_MUTE+t0),kind=CUSTOM_REAL)
874-
! takes complement and shifts scale to (1,100)
875-
! thus, mute factor is 100 at simulation start and 1.0 at starttime_to_mute
876-
mute_factor = abs(1.0 - mute_factor) * 99.0 + 1.0
877-
! positive and negative maximum reach average when wavefield appears
878-
val = real(mute_factor * max_average,kind=CUSTOM_REAL)
869+
if (istamp1 > 0 .and. istamp2 > 0) then
870+
if (STARTTIME_TO_MUTE > TINYVAL) then
871+
! with additional scale factor:
872+
! linear scaling between [0,1]:
873+
! from 0 (simulation time equal to -t0 )
874+
! to 1 (simulation time equals starttime_to_mute)
875+
mute_factor = real(1.d0 - ( STARTTIME_TO_MUTE - ((it-1)*DT-t0) ) / (STARTTIME_TO_MUTE+t0),kind=CUSTOM_REAL)
876+
! takes complement and shifts scale to (1,100)
877+
! thus, mute factor is 100 at simulation start and 1.0 at starttime_to_mute
878+
mute_factor = abs(1.0 - mute_factor) * 99.0 + 1.0
879+
! positive and negative maximum reach average when wavefield appears
880+
val = real(mute_factor * max_average,kind=CUSTOM_REAL)
881+
else
882+
! uses a constant factor
883+
val = real(100.d0 * max_average,kind=CUSTOM_REAL)
884+
endif
885+
! positive and negative maximum
886+
field_display(istamp1) = + val
887+
field_display(istamp2) = - val
888+
if (abs(max_average) > TINYVAL ) field_display = field_display / val
879889
else
880-
! uses a constant factor
881-
val = real(100.d0 * max_average,kind=CUSTOM_REAL)
890+
! poles not found, just normalize by max_average
891+
if (abs(max_average) > TINYVAL ) field_display = field_display / max_average
882892
endif
883-
! positive and negative maximum
884-
field_display(istamp1) = + val
885-
field_display(istamp2) = - val
886-
if (abs(max_average) > TINYVAL ) field_display = field_display / val
887893
endif
888894
else
889895
! no source to mute

0 commit comments

Comments
 (0)