M o d e li n g S ys t Te -F o llo w i r rai n ng O R es e a rc h C o mm u ni ty 4D Variational Data Assimilation Observation Operators Hernan G. Arango ce m em g Ocean Re i al on an M o d e lin g S y s te ROMS 4DVAR ALGORITHMS • • Strong Constraint Conventional (S4DVAR): outer loop, NLM, ADM Incremental (IS4DVAR): inner and outer loops, NLM, TLM, ADM (Courtier et al., 1994) IS4DVAR_OLD: inefficient old conjugate gradient algorithm (is4dvar_ocean_old.h, descent.F) IS4DVAR: new conjugate gradient algorithm, CONGRAD, Fisher 1997 (is4dvar_ocean.h, cgradient.h) IS4DVAR, LANCZOS: conjugate gradient and Lanczos algorithm, Fisher 1997 (is4dvar_ocean_lanczos.h, cgradient_lanczos.h) Weak Constraint Indirect Representer Method (W4DVAR): inner and outer loops, NLM, TLM, RPM, ADM (Egbert et al., 1994; Bennett et al, 1997) Physical Space Statistical Analysis (W4DPSAS): inner and outer loops, NLM, TLM, ADM (Courtier, 1997) Strong Constraint, Incremental 4DVAR Let’s introduce a new minimization variable v, such that: xk = B-1/2(xk + xk-1 – xb) xk = B1/2vk + xk-1 – xb yielding J(vk) = ½(vk)Tvk + ½(Hxk – dk-1)TO-1(Hxk – dk-1) The gradient of J in minimization-space, denoted v J, is given by: v J = vk + BT/2HTO-1(Hxk – dk-1) = vk + BT/2x Jo => vk + W -1/2LT/2GS The background-error covariance matrix can be factored as: B = SCS => S(GL1/2W -1/2)(W -1/2LT/2G)S where S is the background-error standard deviations, C is the background-error correlations which can be factorized as C = C1/2CT/2, G is the normalization matrix which ensures that the diagonal elements of C are equal to unity, L is a 3D self-adjoint filtering operator, and W is the grid cell area or volume. Basic IS4DVAR Procedure (1) Choose an x(0) = xb(0) (2) Integrate NLROMS t [0, ] and save x(t) (NLM at OBS) Inner Loop Outer Loop (a) Choose a x(0) (b) Integrate TLROMS t [0, ] and compute J (TLM at OBS) (c) Integrate ADROMS t [0, ] to yield (ADM forcing at OBS) (d) Compute (e) Use a descent algorithm to determine a “down gradient” correction to x(0) that will yield a smaller value of J (f) Back to (b) until converged (3) Compute new x(0) = x(0) + x(0) and back to (2) until converged Incremental, Strong Constraint 4DVar (IS4DVAR) • Given a first guess (a forward trajectory)… • And given the available data… Incremental, Strong Constraint 4DVar (IS4DVAR) • Given a first guess (a forward trajectory)… • And given the available data… • IS4DVAR computes the changes (or increments) to the initial conditions so that the forward model fits the observations. 4DVAR Observations NetCDF File • • • • • • • • Utility/obs_initial.F Utility/obs_read.F Utility/obs_write.F Utility/obs_scale.F Utility/obs_depth.F Utility/extract_obs.F Adjoint/ad_extract_obs.F Adjoint/ad_misfit.F Metadata Dimensions: survey weight datum Number of different time Number of interpolation weight Observations counter, unlimited dimension Variables: Nobs(survey) survey_time(survey) obs_type(datum) obs_time(datum) obs_lon(datum) obs_lat(datum) obs_depth(datum) obs_Xgrid(datum) obs_Ygrid(datum) obs_Zgrid(datum) obs_error(datum) obs_value(datum) Number of observations per time survey Survey time (days) State variable ID associated with observation Time of observation (days) Longitude of observation (degrees_east) Latitude of observation (degrees_north) Depth of observation (meters or level) X-grid observation location (nondimensional) Y-grid observation location (nondimensional) Z-grid observation location (nondimensional) Observation error, assigned weight Observation value dimensions: Observations NetCDF survey = 1 ; tate_variable = 7 ; datum = UNLIMITED ; // (79416 currently) Variable ζ u v u v temp salt variables: char spherical ; spherical:long_name = "grid type logical switch" ; int Nobs(survey) ; Nobs:long_name = "number of observations with the same survey time" ; double survey_time(survey) ; survey_time:long_name = "survey time" ; survey_time:units = "days since 2000-01-01 00:00:00" ; survey_time:calendar = "365.25 days in every year" ; double obs_variance(state_variable) ; obs_variance:long_name = "global (time and space) observation variance" ; obs_variance:units = "squared state variable units" ; int obs_type(datum) ; obs_type:long_name = "model state variable associated with observation" ; obs_type:units = "nondimensional" ; double obs_time(datum) ; obs_time:long_name = "time of observation" ; obs_time:units = "days since 2000-01-01 00:00:00" ; obs_time:calendar = "365.25 days in every year" ; double obs_depth(datum) ; obs_depth:long_name = "depth of observation" ; obs_depth:units = "meter" ; double obs_Xgrid(datum) ; obs_Xgrid:long_name = "x-grid observation location" ; obs_Xgrid:units = "nondimensional" ; double obs_Ygrid(datum) ; obs_Ygrid:long_name = "y-grid observation location" ; obs_Ygrid:units = "nondimensional" ; double obs_Zgrid(datum) ; obs_Zgrid:long_name = "z-grid observation location" ; obs_Zgrid:units = "nondimensional" ; double obs_error(datum) ; obs_error:long_name = "observation error, assigned weight, inverse variance" ; obs_error:units = "inverse squared state variable units" ; double obs_value(datum) ; obs_value:long_name = "observation value" ; (i1,j1,k1) obs_value:units = "state variable units" ; 8 5 7 6 4 1 ID 1 2 3 4 5 6 7 2 3 (i2,j2,k2) Processing • Use hindices, try_range and inside routines to transform (lon,lat) to (,) • Find how many survey times occur within the data set (survey dimension) • Count observations available per survey (Nobs) and assign their times (survey_time) • Sort the observation in ascending time order and observation time for efficiency • Save a copy of the observation file • Several matlab scripts to process observations ROMS GRID • Horizontal curvilinear orthogonal coordinates on an Arakawa C-grid • Terrain-following coordinates on a staggered vertical grid Curvilinear Transformation Staggered C-Grid, RHO-points Staggered C-Grid, U-points Staggered C-Grid, V-points Vertical Terrain-following Coordinates Vieste (Italy) Dubrovnik (Croatia) Depth (m) Longitude Parabolic Splines Reconstruction PARALLEL TILE PARTITIONS 8x8 Ny } Nx East-West MPI Communications AsendE TILE L ArecvE ArecvW AsendW TILE R receive Jend Jend Nonlinear With Respect To Tile R i-2 i-1 i i+1 i-2 i-1 i i+1 Jstr Jstr send Istr V iL = V iL+1 = TILE L Iend R Vi V iR+1 AsendE Istr V iR-2 = V iR-1 = ArecvE ArecvW Iend L V i-2 V iL-1 TILE R AsendW ad_send Jend Jend With Respect To Tile R Adjoint i-2 i-1 i i+1 i-2 i-1 i i+1 Jstr Jstr ad_receive ad_V iL-2 = Istr Iend L R ad_V i-2 + ad_V i-2 ; ad_ViR-2 = 0 ad_V iL-1 = ad_V iL-1 + ad_V iR-1 ; ad_ViR-1 = 0 Istr ad_V iR = ad_V iR + Iend L i L ; ad_V i =0 ad_V iR+1 = ad_V iR+1 + ad_V iL+1 ; ad_V iL+1 = 0 North-South MPI Communications V jB+2 = V jT+2 ad_V jT+2 = ad_V jT+2 + ad_V jB+2 ; ad_V jB+2 = 0 V jB+1 = V jT+1 ad_V jT+1 = ad_V jT+1 + ad_V jB+1 ; ad_V jB+1 = 0 TILE T TILE T With Respect to Tile B Jend Jend j+2 j+2 AsendS Nonlinear j j-1 send j-1 receive TILE B ArecvS Istr Iend ad_receive Iend ad_send TILE B j+2 j+2 ArecvN j+1 Jend j ArecvS Istr AsendS j+1 Jstr j Jend AsendN j-1 ArecvN j+1 j AsendN j-1 Jstr Jstr Istr V jT Istr Iend B = Vj V jT-1 = V jB-1 ad_V jB = ad_V jB Iend + T j T ; ad_V j =0 ad_V jB-1 = ad_V jB-1 + ad_V jT-1 ; ad_V jT-1 = 0 Adjoint j+1 Jstr Observations LEO-15 THE STATE UNIVERSITY OF NEW JERSEY RUTGERS ul li c a Ri ve NJSOS Kilometers LEO-15 Research Stations M LEO Beach Haven r 0 1 2 Long Beach Great Field Field Station Station Bay Longterm Ecosystem Observatory Little Egg Inlet C ab le Depth Land and Wetlands 1 meter 3 meters 6 meters 10 meters 14 meters 16 meters 18 meters 22 meters Node A Node B Brigantine Inlet LEO-15 Research Area New Jersey Shelf Observing System Brigantine 3km x 3km 1996-Present 30km x 30km 1998-2001 Satellites, Aircraft, Surface RADAR, Glider AUVs 300km x 300km Beginning 2001 Assumptions • All scalar observations are assumed to be at RHO-points. • All vector observations are assumed to be rotated to curvilinear grid, if applicable. Vector observations are always measured at the same location. • All observation horizontal locations are assumed to be in fractional curvilinear grid coordinates. • Vertical locations can be in fractional levels (1:N) or actual depths (negative values). • Removal of tidal signal? • Filtering of non-resolved processes? Observation Operators • Currently, all observations must be in terms of model state variables (same units): – 2D configuration: zeta, ubar, vbar – 3D configuration: zeta, u, v, T, S, … • There is not a time interpolation of model solution at observation times: time - 0.5*dt < ObsTime < time + 0.5*dt • There is not observations quality control (screening) inside ROMS, except ObsScale. • No observation constraints are implemented (Satellite SST measurements) Observation Interpolation • Only spatial linear interpolation is coded. • If land/sea masking, the interpolation coefficients are weighted by the mask. • If shallower than z_r(:,:,N), observations are assigned to the surface level. • If deeper than z_r(:,:,1), observations are assigned to bottom level. Recommedations • Create a NetCDF file for each observation type. • Use a processing program to meld NetCDF observation files (nc_4dvar_meld.m). • Keep a master copy of each observation file, in case that you are running your application at different resolutions. • Decimation of observations. Finite volume representation? BACKGOUND ERROR COVARIANCE Model/Background Error Covariance, B • Use a generalized diffusion squared-root operator (symmetric) as in Weaver et al. (2003): 1/2 B = S C S = S (G L -1/2 W -1/2 ) (W T/2 L G) • The normalization matrix, G, ensure that the diagonal elements of the correlation matrix, C, are equal to unity. They are computed using the exact (expensive) or randomization (cheaper) methods. • The spatial convolution of the self-adjoint filtering operator, 1/2 L , is split in horizontal and vertical components and discretized both explicitly and implicitly. • The model/background standard deviation matrix, S, is computed from long (monthly, seasonal) simulations. -1/2 • The grid cell area or volume matrix, W time invariant. , is assumed to be Model/Background Error Correlation (C) Horizontal Vertical (implicit) Vdecay = 100 m Hdecay = 100 km Model/Background Error Correlation Normalization Coefficients (G) SSH EAC Temperature EAC Bottom Level job_is4dvar.sh set Di r =/ home/ ar ango/ ocean/ t oms/ r eposi t or y/ Pr oj ect s/ doubl e_gyr e # Copy nonl i near model i ni t i al condi t i ons f i l e. cp - p ${ Di r } / Dat a/ gyr e3d_bck. nc gyr e3d_i ni . nc # 10 year mean # Set backgr ound- er r or covar i ance st andar d devi at i ons f i l e. set STDname=. . / Dat a/ gyr e3d_st d. nc # Set backgr ound- er r or covar i ance nor mal i zat i on f act or f i l e set NRMname=. . / Dat a/ gyr e3d_nr m_100k100i . nc # Set obser vat i ons f i l e. #set OBSname=gyr e3d_zSST_obs. nc set OBSname=gyr e3d_zuvTS_obs. nc # Get a cl ean copy of t he obser vat i on f i l e. # i mpor t ant si nce t hi s f i l e i s modi f i ed. Thi s i s r eal l y cp - p ${ Di r } / OBS/ $OBSname . # Modi f y S4DVAR t empl at e i nput scr i pt and speci f y above f i l es. set I S4DVAR=i s4dvar . i n i f ( - e $I S4DVAR) t hen / bi n/ r m $I S4DVAR endi f cp s4dvar . i n $I S4DVAR subst i subst i subst i subst i subst i subst i t ut e t ut e t ut e t ut e t ut e t ut e $I S4DVAR $I S4DVAR $I S4DVAR $I S4DVAR $I S4DVAR $I S4DVAR ocean_st d. nc ocean_nr m. nc ocean_obs. nc ocean_hss. nc ocean_l cz. nc ocean_mod. nc $STDname $NRMname $OBSname gyr e3d_hss. nc gyr e3d_l cz. nc gyr e3d_mod. nc #subst i t ut e $I S4DVAR ocean_hss. nc Runs/ gyr e3d_hss_01. nc #subst i t ut e $I S4DVAR ocean_l cz. nc Runs/ gyr e3d_l cz_01. nc build.sh # anal yt i cal sour ce f i l es, i f any. See t he t empl at es i n User / Funct i onal s. set env MY_HEADER_DI R ${ MY_PROJECT_DI R} #set env MY_ANALYTI CAL_DI R # Put t he bi nar y t o execut e i n t he f ol l owi ng di r ect or y. set env BI NDI R ${ MY_PROJECT_DI R} # Put t he f 90 f i l es i n a pr oj ect speci f i c Bui l d di r ect or y t o avoi d conf l i ct # wi t h ot her pr oj ect s. set env SCRATCH_DI R ${ MY_PROJECT_DI R} / Bui l d # Go t o t he user s sour ce di r ect or y t o compi l e. The opt i ons set above wi l l # pi ck up t he appl i cat i on- speci f i c code f r om t he appr opr i at e pl ace. cd ${ MY_ROMS_SRC} # St op i f act i vat i ng bot h MPI and OpenMP at t he same t i me. i f ( ${ ?USE_MPI } & ${ ?USE_OpenMP} ) t hen echo " You cannot act i vat e USE_MPI and USE_OpenMP at t he same t i me! " exi t 1 endi f # Remove bui l d di r ect or y. i f ( $cl ean == 1 ) t hen make cl ean endi f # Compi l e ( t he bi nar y wi l l go t o BI NDI R set above) . i f ( $par al l el == 1 ) t hen make $NCPUS el se make endi f s4dvar.in Hdecay( i sFsur ) ==Hdecay( i sVst r ) == 100. 0d+3 V- moment um st r ess Hdecay( i sUvel ) == 100. 0d+3 Hdecay( i sVvel ) == 100. 0d+3 Hdecay( i sTvar ) == 100. 0d+3 100. 0d+3 Hdecay( i sTsur ) == 100. 0d+3 100. 0d+3 ! sur f ace ! ! ! ! 3D U- moment um 3D V- moment um 1: NT t r acer s 1: NT sur f ace t r acer s f l ux ! Ver t i cal , i sot r opi c decor r el at i on scal es ( m) . Vdecay( i sUvel ) == 100. 0d0 Vdecay( i sVvel ) == 100. 0d0 Vdecay( i sTvar ) == 100. 0d0 ! 3D U- moment um ! 3D V- moment um ! 1: NT t r acer s 100. 0d0 ! I n t he weak- const r ai nt al gor i t hms, t he f or ci ng er r or covar i ance mat r i x ! i s est i mat ed by scal i ng t he backgr ound er r or covar i ance mat r i x. These val ues ! pr ovi de t he scal i ng f act or s f or each st at e var i abl e. Cf scal Cf scal Cf scal Cf scal Cf scal Cf scal Cf scal Cf scal Cf scal ! ! ! ! ! e( i e( i e( i e( i e( i e( i e( i e( i e( i sFsur ) sUbar ) sVbar ) sUst r ) sVst r ) sUvel ) sVvel ) sTvar ) sTsur ) = = = = = = = = = Pol ynomi al coef f i nor mal i zat i on of i s t he pol ynomi al coef f i ci ent . The expect ed. Coef f i npN2 = Pcoef _N2 = 0. 3d0 0. 3d0 0. 3d0 0. 3d0 0. 3d0 0. 3d0 0. 3d0 0. 3d0 0. 3d0 ! ! ! ! ! ! ! ! ! 0. 3d0 0. 3d0 ci ent s t r acer or der val ues eci ent f or Br unt - Vai sal a f r equency squar ed ( N2) used f or mi sf i t cost f unct i on. The f i r st val ue i n each l i ne wher eas t he second val ue i s t he pol ynomi al expansi on can be ent er ed i n any or der , [ 0: npN2] val ues ar e ar e der i ved f r om a t ypi cal Nor t h At l ant i c pr of i l e. 9 2D var i abl e at RHO- poi nt s 2D var i abl e at U- poi nt s 2D var i abl e at V- poi nt s sur f ace U- moment um st r ess sur f ace V- moment um st r ess 3D var i abl e at U- poi nt s 3D var i abl e at V- poi nt s NT t r acer s NT sur f ace t r acer s f l ux ! degr ee of pol ynomi al ORDER 0 1 2 3 COEFFI CI ENT 0. 00014377915637d+00 8. 22721559660467d- 07 2. 01838193105922d- 09 2. 50856113444129d- 12