使用散点图和世界地图图像在地图上显示流星撞击,宽高比问题(Using a scatter plot and world map image to display meteor impacts on a map, Aspect ratio problems)
因此,我试图在pycharm IDE中使用python在等矩形地图投影(作为标准图像加载)上绘制陨石撞击,这是通过时间递增来“动画”的,以显示从1500年到现在的50年期间的影响。
要做到这一点,我使用经过标准化(表示在0 - 1之间)的经纬度坐标(从NASA csv文件)到散点图上的绘图点的元组列表,然后与地图图像重叠。
简码解释:在第一部分中,normalize_lat_lon从我写过的数据处理文件中提取,该文件对经度和纬度进行了归一化处理。
影响是年,拉特,隆的元组列表。 img是世界地图图像,分辨率为2048 x 1025 1.998 * a是我试图纠正我所遇到的比率问题。 通过将x值乘以1.998(2048/1025),分辨率几乎为2:1。理论上应该允许我相应地进行绘图。
这是主要代码的一部分:
lat_lon = [data.normalise_lat_lon(b, c) fpr a, b, c in impacts] x, y = [1.998*a for a, b in lat_lon], [b for a, b in lat_lon] plt.scatter(x, y, s=200, color='red') plt.imshow(img)
我的问题是缩放散点图以与世界地图图像对齐。 使用上面的修补程序乘以1.998 * a似乎将所有散点图卡在左上角,如下所示。
陨石影响 MCV:代码的简化版本,无需循环其他时间段或需要从nase文件中标准化经纬度
from matplotlib import pyplot as plt plt.ion() plot.title("Meteorite Impacts 1990 - 2000") impacts = [(1994, 0.5, 0.3),(1991, 0.4, 0.3),(1998, 0.1, 0.1),(1992, 0.8, 0.8)] lat_lon = [(b, c) for a, b, c in impacts] x, y = [1.9*a for a, b in lat_lon], [b for a, b in lat_lon] plt.imread("Equirectangular-projection.jpg") plt.scatter(x, y) plt.show()
我可以将https放到项目的git上,供其他人克隆/分叉,不确定我是否允许这样做。
So I'm attempting to plot meteorite impacts using python in the pycharm IDE on a equirectangular map projection(loaded as a standard image) this is "animated" through time incrementing to show impacts in 50 year periods from 1500 to present.
To do this I am using a tuple list of lat and lon coordinates (from a NASA csv file) that have been normalized (represented between 0 - 1) to plot points on a scatter plot this is then overlapped with the map image.
Brief code explanation: In the first part the normalize_lat_lon pulls from a data processing file I have written that normalizes the latitude and longitude.
Impacts is a list of tuples that are Year, Lat, Lon. img is the world map image which resolution is 2048 x 1025 the 1.998*a is my attempt at rectifying the ratio problem I have. As the resolution is almost 2:1 by multiplying the x values by 1.998 (2048/1025) It in theory should allow me to plot accordingly.
This is part of the main code:
lat_lon = [data.normalise_lat_lon(b, c) fpr a, b, c in impacts] x, y = [1.998*a for a, b in lat_lon], [b for a, b in lat_lon] plt.scatter(x, y, s=200, color='red') plt.imshow(img)
My problem is scaling the scatter plot to line up with the world map image. using the above fix multiplying the 1.998*a seems to have all the scatter plot points stuck in the top left hand corner as shown below.
Meteorite Impacts MCV: Simplified version of the code without looping through other time periods or needing to normalise the lat an lon from the nase file
from matplotlib import pyplot as plt plt.ion() plot.title("Meteorite Impacts 1990 - 2000") impacts = [(1994, 0.5, 0.3),(1991, 0.4, 0.3),(1998, 0.1, 0.1),(1992, 0.8, 0.8)] lat_lon = [(b, c) for a, b, c in impacts] x, y = [1.9*a for a, b in lat_lon], [b for a, b in lat_lon] plt.imread("Equirectangular-projection.jpg") plt.scatter(x, y) plt.show()
I could put a https to a git of the project for others to clone/fork, not sure if I'm allowed to do that.
原文:https://stackoverflow.com/questions/33119505
最满意答案
打开EF设计器,单击要提供文档的任何内容,然后在属性选项卡中填写“ 文档 ”字段。啊,你说的是属性,而不是注释。 请参阅此stackoverflow帖子 。
简而言之 - 你不能这样做。 如果您绝对需要属性,则必须编写自己的实体类(POCO),这只在新版本的Entity Framework中支持(在.Net 4.0中)
Open up the EF designer, click on whatever you want to give documentation to, and fill in the " Documentation" field in the properties tab.Ah, you are talking about attributes, not annotations. See this stackoverflow post.
In short - you can't do it. If you absolutely need attributes, you'll have to write your own Entity classes (POCO), which is only supported in the new version of Entity Framework (in .Net 4.0)
相关问答
更多-
如何为Data-First自动创建的实体添加数据注解?(How to add data annotation for entities automatically created by Data-First?)[2019-08-13]
你所要做的就是创建另一个部分类并使用metadatatype属性。 这里是示例代码 //This is generated by EDMX namespace DataLayer { using System; using System.Collections.Generic; public partial class Customer { public Customer() { this.CustomerAddre ... -
构建错误Asp.Net MVC 3实体框架自动生成的文件(Build Error Asp.Net MVC 3 Entity Framework auto generated file)[2023-03-06]
我通过删除现有的edmx类文件并通过给出ado.net实体数据模型类的不同名称再次重新创建自动生成的文件来修复问题。 我也删除了.tt文件中的edmx文件。 谢谢。 I have fixed issue by deleting the existing edmx class file and re-creating the auto-generated file again by giving the different name of ado.net entity data model class. I ... -
如果要覆盖保存更改,可以使用此部分类样式,应注意如果此处的方法未被调用,则通常指示部分类与实际类不匹配,检查命名空间等。 public partial class MyEntities : DbContext { public override int SaveChanges() { try { SavingChanges(); return base.SaveChanges(); } ...
-
生成的类ItemRequest将始终是一个partial类。 这允许您编写一个标有必要数据注释的第二个部分类。 在您的情况下,部分类ItemRequest将如下所示: using System.ComponentModel; using System.ComponentModel.DataAnnotations; //make sure the namespace is equal to the other partial class ItemRequest namespace MvcApplicatio ...
-
实体框架存在复合键的问题,这是自动生成的部分(Entity Framework has issues with composite key which is part auto generated)[2022-06-24]
我发现这篇文章提出了一个建议: http : //wiki.alphasoftware.com/Scope_Identity+in+SQL+Server+with+nested+and+INSTEAD+OF+triggers TL; DR版本是INSTEAD OF INSERT在末尾执行SELECT以返回密钥。 该文章是由于触发器导致SCOPE_IDENTITY()值丢失,但它也适用于此。 所以,我做的是这样的: 触发器现在现在读取 ALTER TRIGGER dbo.IOINS_ChildTable ON ... -
您需要Select一个Template并映射所有属性。 像这样的东西 List Templates = db.tbl_Templates.Select(x => new Template { .TemplateID = x.TemplateID }).ToList( ...
-
关于数据库没有自动编号的地方,我可以考虑三种常用技术。 1)先执行MAX(ID_column)+1以获取下一个ID值。 但是,您需要注意这里的多用户问题。 另外,这些号码不是一次性使用的。 如果您删除一行并添加新行,您将获得相同的ID。 这可能会或可能不会对您造成问题。 2)使用GUID。 几乎保证是唯一的,但是ID列的占位面积很大。 3)使用保存分配的最后一个ID的单独密钥表。 这确保数字永远不会被重用,但会在您的数据库中添加一个额外的表。 There are three general techniqu ...
-
打开EF设计器,单击要提供文档的任何内容,然后在属性选项卡中填写“ 文档 ”字段。 啊,你说的是属性,而不是注释。 请参阅此stackoverflow帖子 。 简而言之 - 你不能这样做。 如果您绝对需要属性,则必须编写自己的实体类(POCO),这只在新版本的Entity Framework中支持(在.Net 4.0中) Open up the EF designer, click on whatever you want to give documentation to, and fill in the ...
-
您正在使用代码优先方法,这将跟踪与该模型对应的模型和数据库表。因此,您无法更改模型。选项是启用迁移或禁用模型检查。 检查此链接以进行迁移 https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-在安-ASP净MVC应用程序 After looking at ...
-
我可以直接使用Entity Framework生成的模型吗?(Can I use the generated model by Entity Framework directly?)[2022-10-26]
我认为你的意思是你已经通过设计师生成了模型。无论你是使用Code First Approach(先创建类)还是使用Database First方法都没关系。 模型是表的表示,您可以通过Dbcontext访问模型,其中模型表示为DbSets。您可以使用dbcontext基于实现的逻辑对模型/表进行任何类型的操作。 业务逻辑不应该是模型的一部分,但理想情况下应该是远离它的两层。 业务逻辑层应调用数据访问层(DAL),DAL应具有通过EF中的dbContext访问/操作数据的逻辑。 请参阅存储库模式。 ( htt ...