首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用SPLAT预测天线覆盖度

用SPLAT预测天线覆盖度
EN

Data Science用户
提问于 2022-01-06 16:16:08
回答 1查看 40关注 0票数 0

我一直试图根据天线特性(如高度、lat和长等)来预测网络覆盖。偶然发现这个包现在似乎处于休眠状态(https://github.com/NZRS/wavetrace)

这是我得到的错误信息-

代码语言:javascript
复制
FileNotFoundError                         Traceback (most recent call last)
/var/folders/70/qd0s3l2d6fnf4jk2n2w0fryw0000gp/T/ipykernel_96803/1928621339.py in <module>
     22 out_path = TMP_DIR+'/splat_files'
     23 wt.process_topography(topography_path, out_path, 
---> 24   high_definition=high_definition)
     25 
     26 #%ll -h {out_path}

~/PycharmProjects/Netowrth/wavetrace/wavetrace/main.py in process_topography(in_path, out_path, high_definition)
    418         # Convert to SDF
    419         cp = subprocess.run([splat, f.name], cwd=str(f.parent),
--> 420           stdout=subprocess.PIPE, universal_newlines=True, check=True)
    421 
    422         # Get name of output file, which SPLAT! created and which differs

~/opt/anaconda3/envs/Netowrth/lib/python3.7/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
    486         kwargs['stderr'] = PIPE
    487 
--> 488     with Popen(*popenargs, **kwargs) as process:
    489         try:
    490             stdout, stderr = process.communicate(input, timeout=timeout)

~/opt/anaconda3/envs/Netowrth/lib/python3.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    798                                 c2pread, c2pwrite,
    799                                 errread, errwrite,
--> 800                                 restore_signals, start_new_session)
    801         except:
    802             # Cleanup if the child failed starting.

~/opt/anaconda3/envs/Netowrth/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1549                         if errno_num == errno.ENOENT:
   1550                             err_msg += ': ' + repr(err_filename)
-> 1551                     raise child_exception_type(errno_num, err_msg, err_filename)
   1552                 raise child_exception_type(err_msg)
   1553 

FileNotFoundError: [Errno 2] No such file or directory: 'srtm2sdf': 'srtm2sdf'

这是我在这里使用的密码-

代码语言:javascript
复制
out_path = TMP_DIR+'/splat_files'
wt.process_topography(topography_path, out_path, 
  high_definition=high_definition)

请注意,如果您想查看整个工作流程,也可以在这里找到这个python笔记本。

根据该模块,这是process_topography的定义。

代码语言:javascript
复制
import sys
from pathlib import Path
import shutil
import json
import csv
import re
import math

from shapely.geometry import Point
import requests

def process_topography(in_path, out_path, high_definition=False):
    """
    Convert each SRTM HGT topography file in the directory ``in_path`` to a SPLAT! Data File (SDF) file in the directory ``out_path``,     creating the directory if it does not exist.
    If ``high_definition``, then assume the input data is high definition.

    INPUT:
        - ``in_path``: string or Path object specifying a directory
        - ``out_path``: string or Path object specifying a directory
        - ``high_definition``: boolean

    OUTPUT:
        None.

    NOTES:
        - Calls SPLAT!'s ``srtm2sdf`` or ``srtm2sdf-hd`` 
          (if ``high_definition``) command to do the work
        - Raises a ``subprocess.CalledProcessError`` if SPLAT! fails to 
          convert a file
        - Each SRTM1 or SRTM3 file must have a name of the form <SRTM tile ID>[.something].hgt.zip or <SRTM tile ID>[.something].hgt, e.g. S36E173.SRTMGL3.hgt.zip 
    """
    in_path = Path(in_path)
    out_path = Path(out_path)
    if not out_path.exists():
        out_path.mkdir(parents=True)

    splat = 'srtm2sdf'
    if high_definition:
        splat += '-hd'

    sdf_pattern = re.compile(r"[\d\w\-\:]+\.sdf")

    for f in in_path.iterdir():
        if not (f.name.endswith('.hgt') or f.name.endswith('.hgt.zip')):
            continue

        # Unzip if necessary
        is_zip = False
        if f.name.endswith('.zip'):
            is_zip = True
            shutil.unpack_archive(str(f), str(f.parent))
            tile_id = f.name.split('.')[0]
            f = f.parent/'{!s}.hgt'.format(tile_id)

        # Convert to SDF
        cp = subprocess.run([splat, f.name], cwd=str(f.parent),
          stdout=subprocess.PIPE, universal_newlines=True, check=True)

        # Get name of output file, which SPLAT! created and which differs
        # from the original name, and move the output to the out path
        m = sdf_pattern.search(cp.stdout)
        name = m.group(0)        
        src = in_path/name
        tgt = out_path/name
        shutil.move(str(src), str(tgt))

        # Clean up
        if is_zip:
            f.unlink()

任何帮助都是非常感谢的。从错误来看,srtmsdf必须是一个文件夹,但是根据python子进程,它必须是一个函数。

EN

回答 1

Data Science用户

发布于 2022-01-06 16:32:55

似乎这个函数试图调用SPLAT!命令行,对srtm2sdf中的所有文件使用in_path。当命令行程序不存在时,尝试使用subprocess.run运行命令行程序(即在试图在命令行上运行命令时返回“命令未找到”错误)将给出一个FileNotFoundError,而不是从命令行获得的实际错误。基于此,您似乎还没有安装SPLAT!,它是这个包的要求的一部分。因此,请确保已安装了此包工作所需的所有先决条件(SPLAT!、GDAL和ImageMagick)。

票数 1
EN
页面原文内容由Data Science提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://datascience.stackexchange.com/questions/106771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档