m_obj.model_fn = None
m_obj.write_model_file(**{
    'save_path': sv_path,
    'model_fn_basename': 'mont_topography.rho'
})

#write new data file
d_obj.center_stations(m_obj.model_fn)
d_obj.change_data_elevation(m_obj.model_fn)

n_dfn = d_obj.write_data_file(fn_basename=r"mont_data_topo_c.dat",
                              compute_error=False,
                              fill=False,
                              elevation=True)

# write covariance file
cov = modem.Covariance()
cov.smoothing_east = 0.4
cov.smoothing_north = 0.4
cov.smoothing_z = 0.4
cov.save_path = sv_path
cov.write_covariance_file(model_fn=m_obj.model_fn)

#m_obj.write_vtk_file()
#d_obj.write_vtk_station_file()

mm = modem.ModelManipulator(model_fn=m_obj.model_fn,
                            data_fn=n_dfn,
                            depth_index=26,
                            xlimits=(-10, 10),
                            ylimits=(-10, 10))
mod_obj.pad_north = 8
mod_obj.pad_method = 'extent1'
mod_obj.pad_stretch_h = 1.8
mod_obj.pad_z = 5
mod_obj.n_layers = 50
mod_obj.z1_layer = 10
mod_obj.z_target_depth = 30000.

#--> here is where you can rotate the mesh
mod_obj.mesh_rotation_angle = 0

mod_obj.make_mesh()
mod_obj.plot_mesh()

mod_obj.save_path = save_path
mod_obj.write_model_file(
    model_fn=os.path.join(save_path, r"shz_modem_sm_02.rho"))

#==============================================================================
# make the covariance file
#==============================================================================
cov = modem.Covariance(grid_dimensions=mod_obj.res_model.shape)
cov.smoothing_east = 0.4
cov.smoothing_north = 0.4
cov.smoothing_z = 0.4
cov.smoothing_num = 1

cov.write_covariance_file(os.path.join(save_path, 'covariance.cov'))

mod_obj.print_mesh_params()