Skip to content

Commit

Permalink
remove lat lon vectors from matlab write
Browse files Browse the repository at this point in the history
remove lat lon vectors from read_obs
remove insane sanity check
  • Loading branch information
amfox37 committed Dec 22, 2023
1 parent 565c868 commit 544a119
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,7 @@
netcdf.putAtt(ncid, varid_end_time, 'long_name', 'end time');
netcdf.putAtt(ncid, varid_end_time, 'axis', 'T');
netcdf.putAtt(ncid, varid_end_time, 'units', 'days since 1950-01-01 00:00:00.0 +0000');

varid_lon = netcdf.defVar(ncid, 'lon', float_precision, [dimid_lon]);
netcdf.putAtt(ncid, varid_lon, 'standard_name', 'longitude');
netcdf.putAtt(ncid, varid_lon, 'long_name', 'lower left longitude of gridcell');
netcdf.putAtt(ncid, varid_lon, 'units', 'degrees_east');
netcdf.putAtt(ncid, varid_lon, 'axis', 'X');

varid_lat = netcdf.defVar(ncid, 'lat', float_precision, [dimid_lat]);
netcdf.putAtt(ncid, varid_lat, 'standard_name', 'latitude');
netcdf.putAtt(ncid, varid_lat, 'long_name', 'lower left latitude of gridcell');
netcdf.putAtt(ncid, varid_lat, 'units', 'degrees_north');
netcdf.putAtt(ncid, varid_lat, 'axis', 'Y');


varid_om = netcdf.defVar(ncid, 'o_mean', float_precision, [dimid_lat dimid_lon dimid_pentad]);
netcdf.defVarDeflate(ncid,varid_om,true,true,compression_level);
netcdf.putAtt(ncid, varid_om, 'standard_name', 'observation mean');
Expand Down Expand Up @@ -188,8 +176,6 @@
netcdf.putVar(ncid, varid_start_time, tmp_start_time);
netcdf.putVar(ncid, varid_end_time, tmp_end_time);

netcdf.putVar(ncid, varid_lon, ll_lons);
netcdf.putVar(ncid, varid_lat, ll_lats);
netcdf.putVar(ncid, varid_ll_lon, ll_lon);
netcdf.putVar(ncid, varid_ll_lat, ll_lat);
netcdf.putVar(ncid, varid_d_lon, d_lon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8184,10 +8184,6 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &
! start_time:standard_name = "start time" ;
! double end_time(pentad) ;
! end_time:standard_name = "end time" ;
! double lon(lon) ;
! lon:standard_name = "longitude" ;
! double lat(lat) ;
! lat:standard_name = "latitude" ;
! double o_mean(pentad, lon, lat) ;
! o_mean:standard_name = "observation mean" ;
! double o_std(pentad, lon, lat) ;
Expand Down Expand Up @@ -8224,12 +8220,6 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &
real, intent(inout), dimension(N_catd) :: tmp_obs
real, intent(inout), dimension(N_catd) :: tmp_std_obs

! ----------------------------------------------------------

! local variables

real, parameter :: tol = 0.99 ! [degree lat/lon] for sanity check (should never kick in)

! -------------------

character(300) :: fname
Expand All @@ -8250,7 +8240,6 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &
integer, dimension(:), allocatable :: sclprm_tile_id
integer, dimension(:), allocatable :: pentads

real, dimension(:), allocatable :: sclprm_lon, sclprm_lat
real, dimension(:,:), allocatable :: sclprm_mean_obs, sclprm_std_obs
real, dimension(:,:), allocatable :: sclprm_mean_mod, sclprm_std_mod
real, dimension(:,:), allocatable :: sclprm_min_mod, sclprm_max_mod
Expand Down Expand Up @@ -8306,8 +8295,6 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &

! Get the variable IDs

ierr = nf90_inq_varid(ncid, 'lon', lon_varid)
ierr = nf90_inq_varid(ncid, 'lat', lat_varid)
ierr = nf90_inq_varid(ncid, 'o_mean', o_mean_varid)
ierr = nf90_inq_varid(ncid, 'o_std', o_std_varid)
ierr = nf90_inq_varid(ncid, 'm_mean', m_mean_varid)
Expand All @@ -8322,13 +8309,6 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &
ierr = nf90_get_var(ncid, dlon_varid, dlon)
ierr = nf90_get_var(ncid, dlat_varid, dlat)

! Read lon and lat variables

allocate(sclprm_lon(N_lon), sclprm_lat(N_lat))

ierr = nf90_get_var(ncid, lon_varid, sclprm_lon)
ierr = nf90_get_var(ncid, lat_varid, sclprm_lat)

start = [1, 1, pp]
icount = [N_lat, N_lon, 1 ]

Expand Down Expand Up @@ -8371,16 +8351,6 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &
i_ind = ceiling((this_lon - ll_lon)/dlon)
j_ind = ceiling((this_lat - ll_lat)/dlat)

! Sanity check (against accidental use of wrong tile space)

if ( abs(tile_coord(i)%com_lat-sclprm_lat(j_ind))>tol .or. &
abs(tile_coord(i)%com_lon-sclprm_lon(i_ind))>tol ) then

err_msg = 'Lat/lon diff beyond tolerance'
call ldas_abort(LDAS_GENERIC_ERROR, Iam, err_msg)

end if

! Check for no-data-values in observation and fit parameters
! (any negative number could be no-data-value for observations)

Expand Down Expand Up @@ -8421,9 +8391,7 @@ subroutine scale_obs_sfmc_zscore( N_catd, tile_coord, &
end if

end do

deallocate(sclprm_lon)
deallocate(sclprm_lat)

deallocate(sclprm_mean_obs)
deallocate(sclprm_std_obs)
deallocate(sclprm_mean_mod)
Expand Down

0 comments on commit 544a119

Please sign in to comment.