Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pedotransfer function doesn't check is the writable permissions #8

Open
mosoriob opened this issue Jul 28, 2021 · 1 comment
Open

Comments

@mosoriob
Copy link

# Copy RTI file from topo to soil directory
topo_rti_file = topo_dir + site_prefix + '.rti'
soil_rti_file = soil_dir + site_prefix + '.rti'
if not Path(topo_rti_file).exists():
    print("error")
if not Path(soil_rti_file).exists():
    print("error")
print(topo_rti_file)
print(soil_rti_file)
print(out_bounds)
print(out_xres_sec)
print(out_yres_sec)
shutil.copyfile( topo_rti_file, soil_rti_file)
pedotransfer.save_soil_hydraulic_vars( site_prefix=site_prefix,
         in_dir=src_soil_dir, out_dir=soil_dir,
         out_bounds=out_bounds, REPORT=False,
         out_xres_sec=out_xres_sec, out_yres_sec=out_yres_sec,
         RESAMPLE_ALGO='bilinear')

The error is:

/home/jovyan/TF_Tests/Tana_120sec/__topo/Tana_120sec.rti
/home/jovyan/TF_Tests/Tana_120sec/__soil/Tana_120sec.rti
[36.4, -3.15, 40.75, 0.69]
120.0
120.0

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-25-005dc04f4761> in <module>
     12 print(out_yres_sec)
     13 shutil.copyfile( topo_rti_file, soil_rti_file)
---> 14 pedotransfer.save_soil_hydraulic_vars( site_prefix=site_prefix,
     15          in_dir=src_soil_dir, out_dir=soil_dir,
     16          out_bounds=out_bounds, REPORT=False,

~/topoflow/topoflow/utils/pedotransfer.py in save_soil_hydraulic_vars(site_prefix, in_dir, out_dir, out_bounds, REPORT, out_xres_sec, out_yres_sec, RESAMPLE_ALGO)
   1376     # Almost ready;  still need to create an RTI file
   1377     #----------------------------------------------------
-> 1378     transform_isric_soil_grid_files( site_prefix,
   1379            in_dir=in_dir, out_dir=out_dir,
   1380            out_bounds=out_bounds,

~/topoflow/topoflow/utils/pedotransfer.py in transform_isric_soil_grid_files(site_prefix, in_dir, out_dir, out_bounds, out_xres_sec, out_yres_sec, RESAMPLE_ALGO, IN_MEMORY, REPORT)
    722         #-------------------------------------------
    723         if not(BAD_BOX):
--> 724             grid2 = rg.gdal_regrid_to_dem_grid( ds_in, tmp_file,
    725                         out_bounds, out_xres_deg, out_yres_deg,
    726                         ### DEM_bounds, DEM_xres, DEM_yres,

~/topoflow/topoflow/utils/regrid.py in gdal_regrid_to_dem_grid(ds_in, tmp_file, DEM_bounds, DEM_xres_deg, DEM_yres_deg, nodata, RESAMPLE_ALGO, VERBOSE, IN_MEMORY)
    895         resampleAlg = resample_algo )
    896 
--> 897     grid = ds_tmp.ReadAsArray()
    898 
    899     ds_tmp = None   # Close tmp_file

AttributeError: 'NoneType' object has no attribute 'ReadAsArray'
@mosoriob
Copy link
Author

mosoriob commented Aug 1, 2021

Topoflow tries to write a temporal files in the src_soil_dir and doesn't check if it can write

@mosoriob mosoriob changed the title Unable to Create Soil Hydraulic Property Grids (via Pedotransfer) Pedotransfer function doesn't check is the writable permissions Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant