首页 \ 问答 \ 变量的二维(Double dimension of a variable)

变量的二维(Double dimension of a variable)

这是我第一次用Python进行编程(之前我使用过NCL),并且尝试将变量rad_coolprec的经度维加 。 但是我对Python的语法有问题,并得到错误:

IndexError: list assignment index out of range

这是我的代码:

n=np.size(time_sat)
m=np.size(lat_sat)
l=np.size(lon_sat)*2
prec_double=[[n],[m],[l]]
rad_cool_double=[[n],[m],[l]]

for j in range(0,720):
    if(j<=359):
      rad_cool_double[:][:][j]=rad_cool[:][:][j]
      prec_double[:][:][j]=prec[:][:][j]
    else:
       rad_cool_double[:][:][j]=rad_cool[:][:][j-np.size(lon_sat)]
       prec_double[:][:][j]=prec[:][:][j-np.size(lon_sat)] 

任何人都可以帮助我吗?

干杯,狮子座


It is my first time programming with Python (I used NCL before) and I try to double the longitude dimension of my variables rad_cool and prec. But I have a problem with the syntax of Python and get the error:

IndexError: list assignment index out of range

That's my code:

n=np.size(time_sat)
m=np.size(lat_sat)
l=np.size(lon_sat)*2
prec_double=[[n],[m],[l]]
rad_cool_double=[[n],[m],[l]]

for j in range(0,720):
    if(j<=359):
      rad_cool_double[:][:][j]=rad_cool[:][:][j]
      prec_double[:][:][j]=prec[:][:][j]
    else:
       rad_cool_double[:][:][j]=rad_cool[:][:][j-np.size(lon_sat)]
       prec_double[:][:][j]=prec[:][:][j-np.size(lon_sat)] 

Can anyone help me with that?

Cheers, Leo


原文:https://stackoverflow.com/questions/42991256
更新时间:2022-01-05 14:01

最满意答案

我已经为Notepad ++安装了XML Tools插件

然后使用“插件 - > XML工具 - >漂亮的打印(仅限XML - 带换行符)”,这解决了我的格式问题。


I have installed the XML Tools plugin for Notepad++.

Then used the "Plugins --> XML Tools --> Pretty print (XML only - with line breaks)" and that solved my formatting problem.

相关问答

更多
  • 职称电脑初级[2023-01-21]

    notepad
  • 编辑cpp.xml文件并添加您想要的所有关键字和功能描述。 只需确保按字母顺序添加它们,否则它们将不会显示。 另一个选项是在“设置” - >“首选项”对话框的“ 自动完成”区域中选择“ 函数”和“单词完成 ” 。 NPP将建议当前文件中以您键入的前N个字母开头的每个“单词”(在“自动完成”控件中选择N的值)。 Edit the cpp.xml file and add all the keywords and function descriptions you'd like. Just make sure ...
  • 在搜索对话框中设置搜索模式“正则表达式”,然后使用以下正则表达式: Members: [^0] Set search mode "regular expression" in the search dialog, then use the following regular expression: Members: [^0]
  • 你可以通过两次通过。 第一遍:用空字符串替换\s+ ,就像你做的那样。 第二关: (Item\.?)(\d+)\.?(.*?)(?=Item\.?\d+|\Z) "$1 $2":"$3", .*? 是懒惰的 ,它会尝试匹配尽可能少的字符,但是前瞻(?=Item\d+\.|\Z)强制它匹配,直到它跟着另一个Item\d+\. 或字符串的结尾( \Z )。 You can do this with two passes. First pass: replace \s+ with an empty strin ...
  • 相当简单:user-folder中有一个session.xml文件,用于保存打开的文件并包含指向它们的链接。 如果文件尚未保存,则它也存储在用户文件夹中。 Windows中的用户文件夹位于: C:\Users\your user\AppData\Roaming\Notepad++ 有session.xml。 在任何编辑器中打开它,您会看到打开的文件。 未保存的文件指向备份文件夹,文件名为new 1 @ 2015-10-05_114609希望有所帮助。 Fairly simple: There's a se ...
  • 只需按Ctrl + F或从菜单 - 搜索 - >查找,然后在搜索字段中键入您的字符串。 在方向选择Up,它将从结束开始。(确保在所有这些之前你没有将鼠标指向文本的任何位置,或者它在文件中的第一个字符之前。) Just press Ctrl+F or from the Menu - Search -> Find and then type your string in search field. In direction choose Up, and it will start from the end.(M ...
  • 我已经为Notepad ++安装了XML Tools插件 。 然后使用“插件 - > XML工具 - >漂亮的打印(仅限XML - 带换行符)”,这解决了我的格式问题。 I have installed the XML Tools plugin for Notepad++. Then used the "Plugins --> XML Tools --> Pretty print (XML only - with line breaks)" and that solved my formatting pro ...
  • 这是因为您的MATLAB编辑器设置为使用等宽字体,例如Courier(即所有字符设计为具有完全相同宽度的字体),但您的Notepad ++不是。 在Notepad ++中,您可以使用菜单Settings - > Style Configurator设置字体。 从语言列表中选择“MATLAB”(或者实际上您可能希望选择“全局样式”,为所有语言执行此操作),并将字体设置为等宽字体,如Courier。 或者,您可以下载更现代的编程字体,如Consolas,ProFont,Monofur,Proggy或Incons ...
  • 我不知道这个插件。 但这可以分两步完成。 将所有前导空格和制表符替换为空 选择行并按ctrl + j 搜索字符串: ^ [\ s \ t] * I don't know any plugin for this. But this can be done in two steps. Replace all leading space and tab to empty Select the lines and hit ctrl + j Search String : ^[\s\t]*
  • 正如评论中指出的那样,它们通常被称为代码片段,你会在SnippetPlus插件中找到对它们的良好支持。 As pointed out in the comments, they're often called code snippets, and you'll find good support for these in the SnippetPlus plugin.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)