大学python笔记_天文数据处理笔记之python(1)

本文介绍了如何使用Python进行天文数据处理,包括NumPy、SciPy、Matplotlib、Astropy等常见库的用途。文章还讨论了Python安装科学计算包的方法,并通过函数定义和测试、计算平均值、读取数据等示例,详细讲解了Python在天文数据处理中的应用。
摘要由CSDN通过智能技术生成

前阵子学完了coursera上悉尼大学的天文数据处理课程,感觉非常适合想学习天文的python初学者所以分享出来,顺便复习一下,网课的地址一会补在评论里。所有的笔记都记录在onenote上,为了方便观看先上图片,想要复制代码的可以往下看,最下面是自己遇到的问题和解答,大家有任何问题也欢迎讨论,一起进步。fb3bab304b85c8d59b6a2fdf33a8f4553ba5b98a.png

python的标准程序已经可以处理很多内容,不过天文的程序开发者为社区编写了许多用于数据处理的程序

In the astronomy community, the most common modules include:

• NumPy – support for numerical computing and matrices;

• SciPy – fundamental libraries for scientific computing;

• Matplotlib – powerful plotting and data visualisation;

• Astropy – community library for astronomy.

We have many modules installed on Grok and throughout this course we'll show you how to use them.

NumPy and Astropy程序包并不在标准python当中,需要分别下载

通常在官网有他们的安装说明

目前通常使用的两个方法:

• a binary installer (you must use the right version for your Python version, operating system and CPU);

• Python's pip installation tool.

另外,也可以使用传统的python安装包 such as Enthought Canopy, Anaconda Python or Python(x, y) that include a large number of scientific and engineering packages. Anaconda and Python(x,y) are completely free, and Canopy is free for students.

所有软件都在linux或者mac上运行,如果是windows用户需要安装虚拟机

函数定义

大多数问题会要求您编写一个需要一些输入并返回结果的函数。

As a quick recap, Python's function syntax works like this:

def func(arg1, arg2, arg3, ...):

return

Function definitions start with the def keyword, followed by the name of the function, and a list of arguments in round brackets.

The body of the function is indented and values are returned using the return statement.

例子:

def double(val):

return val + val

print(double(3))

print(double('3'))

输出结果:

6

33

在submit程序之前测试它的两种方法:

1. Main script environment

您可以使用以下技巧保护您的测试

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值