好的,这是场景。我有一个我称之为 G的大图,其中包含每个节点(x 和 y 坐标)以及连接边的位置信息。图 G 是基本事实。现在我有一个较小的图,我称之为“sub”,其中包含表示包含 x 和 y 位置误差的测量值的节点。我需要将 sub 的节点投影到 G 上,这会保留沿 G 的明显正确路径。(请参阅附加的图像和代码)。
我有代码可以将任何单个节点投影到图形上,但是单个节点的放置通常会导致从投影节点 a 到投影节点 f 的路径包含沿 G 的短进出不连续性(不是在这个特定示例中,我的真正问题是更大、更复杂的图,这会一直导致这些不连续性)。我的投影方法可能是问题所在,因为我只是检查距离被测节点最近的两个节点,然后在这两个节点之间投影该节点。在这个例子中,右上角的红色节点可能会被投影到右上角的黑色对角边上,而不是垂直边上。
我觉得必须有一种方法可以对 G 上的路径子进行某种最小二乘拟合,但我似乎无法找到类似这样的任何细节。
是否存在算法来做到这一点?
如果我的措辞不好,我很抱歉,我对使用图表很陌生,不确定常见的命名法是什么。
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import collections as mc
def GetPlottingData(graph):
lines = []
for edge in graph.edges():
x0 = graph.nodes[edge[0]]['x']
y0 = graph.nodes[edge[0]]['y']
x1 = graph.nodes[edge[1]]['x']
y1 = graph.nodes[edge[1]]['y']
lines.append([(x0, y0), (x1, y1)])
node_x = []
node_y = …Run Code Online (Sandbox Code Playgroud) 我正在使用 matplotlib 在 python 中绘制二维数组,但在格式化刻度线时遇到问题。首先,我的数据目前被组织为带有(海拔、纬度)的二维数组。我正在绘制电子密度值作为高度和纬度的函数(基本上是特定时间的纵向切片)。
我想以 30 度为间隔标记从 -90 到 90 度的 x 轴,并使用另一个高程数组标记 y 值(每个模型运行都有不同的高程值,因此我无法手动分配任意高程)。我有一个带有纬度值的数组,另一个带有海拔值的数组都是一维数组。
这是我的代码:
from netCDF4 import Dataset
import numpy as np
import matplotlib.pyplot as plt
#load the netcdf file into a variable
mar120="C:/Users/WillEvo/Desktop/sec_giptie_cpl_mar_120.nc"
#grab the data into a new variable
fh=Dataset(mar120,mode="r")
#assign model variable contents to python variables
lons=fh.variables['lon'][:]
lats=fh.variables['lat'][:]
var1=fh.variables['UN'][:]
#specifying which time and elevation to map
ionst=var1[0,:,:,21]
ionst=ionst[0:len(ionst)-1]
#close the netCDF file
fh.close()
#Set the figure, size, and resolution
plt.figure(figsize=(8,6), dpi=100, facecolor='white')
plt.subplot(1,1,1)
plt.imshow(ionst, …Run Code Online (Sandbox Code Playgroud) 我遇到了一个令人难以置信的令人沮丧的问题,Dockerfile 中的 COPY 命令成功复制了除一个之外的所有应用程序文件。我没有 .dockerignore 文件,所以我知道该文件不会以这种方式从构建中排除。
\n注意:我确实有一个.gitignore排除file2.json我不想版本的情况。但正如您将在下面看到的,我是从本地文件夹构建的,而不是从克隆/签出远程构建的,所以我不明白为什么.gitignore在这种情况下会影响 docker 构建。
下面是我的目录的样子:
\n$ tree -a -I .git app\napp\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 data\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file1.txt\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file2.json\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 file3.txt\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 file4.yml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 somefile2.py\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 somefile.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .gitignore\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 requirements.txt\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 setup.py\nRun Code Online (Sandbox Code Playgroud)\n这就是我的 Dockerfile 中的内容
\nFROM ubuntu:18.04\nFROM python:3.7\n \nCOPY . /app\n \nRUN cp app/app/data/file2.json ~/.somenewhiddendirectory\n \nRUN pip install app/.\n \nENTRYPOINT ["python", "app/app/somefile.py"]\nRun Code Online (Sandbox Code Playgroud)\n由于某种原因,在通话file2.json过程中没有被复制,当我尝试在其他地方复制COPY . /app时,我收到错误。cp我已经完成了类似的调用 …
假设我有一个如下所示的 cloudbuild.yaml 文件:
steps:
- name: 'gcr.io/cloud-builders/docker'
id: build
args: ['build', '-t', 'us.gcr.io/${PROJECT_ID}/image_name', '--build-arg', 'secret=$$SECRET', '.']
secretEnv: ['SECRET']
images:
- 'us.gcr.io/${PROJECT_ID}/image_name'
availableSecrets:
secretManager:
- versionName: projects/project/secrets/my_secret/versions/latest
env: 'SECRET'
Run Code Online (Sandbox Code Playgroud)
现在,--build-arg 正在为 Docker secretarg 分配值$SECRET,而不是实际存储在密钥中的值。在此步骤中如何访问秘密值?我可以在网上找到的所有示例都说添加 bash 入口点,但仅适用于实际上未执行构建调用的步骤。