Python 作业辅导

Python程序辅导 辅导Python编程作业 Assignment

Finding water level changes via satellite imagery

Please read this assignment carefully.
This coursework is concerned with the creation of a library to analyse data from different instruments onboard
a satellite. The instruments provide daily updates from a piece of land that can be used to track
water levels at different locations.
This assignment asks you to work collaboratively within your team to create a package. For that you will
need to write some code for querying, loading and analysing a dataset about different portions of land in
a map. We will describe how the code must behave, but it is up to you to fill in the implementation. The
package needs to follow all the good practices learnt in the course, that is, the package should: be version
controlled; include tests; provide documentation and doctests; set up command line interfaces; and
be installable. Besides this, you will also need to modify an existing implementation of a provided script
to make it more readable, more efficient, and measure its performance.
The collaboration aspect should be organised and managed using GitHub.
The exercise will be semi-automatically marked, so it is very important that your solution adheres to the
correct interface, file and folder name convention and structure, as defined in the rubric below. An otherwise
valid solution that doesn’t work with our marking tool will not be given credit.
For this assignment, you can use the Python standard library and other libraries you may wish to use (but
make sure they are clearly set as dependencies when installing your package). Your code should work with
Python 3.9.
First, we set out the problem we are solving. Next, we specify the target for your solution in detail. Finally,
to assist you in creating a good solution, we state the marking scheme we will use.
1 Background information
The Irish Space Agency has launched Aigean, an Earth observation satellite to monitor an area around
Lough Ree. Recently, rainfall has decreased in the area, and during the latest years droughts have become
more frequent and more severe. With the instruments on board Aigean the scientific community will be
able to obtain better data about the water levels and the erosion of the land, and therefore will be able to
generate more accurate predictions.
However, the Irish Space Agency sadly hasn’t provided any software tools to do this analysis!
Thankfully, Aoife O’Callaghan, a geology PhD student at the Athlone City Institute, has set the objective
to solve this problem by creating an open-source package to analyse Aigean data. Aoife has some ideas of
what she would like the package to do, but she doesn’t have a research software development background
beyond how to install and use Python libraries. That’s why Aoife has contacted you!
You and your group members agree this is a great tool to offer to the community and have decided to put all
your brains together to come up with an easy-to-use Python library to analyse and visualise Aigean satellite
data.

What do we know? What do we have? What do we want?
1. Aigean has multiple instruments, as an starting point we only need to focus on the imagers and the
radar.
2. There are three imagers on board of the spacecraft. Their only differences are in their resolution (how
much area they cover per pixel) and their field-of-view (how much they can see in a single image).
3. The three imagers are called: Lir, Manannan and Fand. •Lir has the largest field-of-view, but the smaller resolution with a pixel size of 20 m per pixel; •Manannan provides a smaller field-of-view with a better resolution of 10 m per pixel; and •Fand has the smallest field-of-view but a very high resolution of 1 m per pixel.
4. The radar is called Ecne and it provides three measurements for the deepest areas in the region.
5. Each instrument provides data in a different format, but the imagers share a common set of metadata.
6. A number of images are taken every day, however not all the land is fully covered in a single day, it
depends on the satellite orbits. Ecne, however, takes always measurements of the same points.
7. All the data is available at the Irish Space Agency webservice archive.
8. The Python library – aigeanpy – should be able to query, download, open, process and visualise the
satellite images.
9. We want to create three command line tools to provide access to some functionality from outside
Python.
10. We have a script from a post-doc of Aoife’s group that implements the so-called k-means algorithm for
clustering data points. We want to include it in our library too! It will help people to analyse different
land areas based in their parameters.
11. We are also interested on how to make our code, specifically the k-means algorithm, more efficient.
This will be used to analyse Ecne’s data.
12. We want this tool to be used by any researcher, so it needs to be easy to install and use. This includes
having good documentation about how to use it and how to acknowledge it in the publications that
benefit from it.
13. And we also want to make it easier to others to contribute so we need to provide information about
how we would like others to contribute.
Let’s look at what we’ve got access to already:
1.1 The data archive webservice
The Irish Space Agency data archive is located at: https://dokku-app.dokku.arc.ucl.ac.uk/isa-archive/ and
their main page provides some information about how to query this service.
The website offers two services. One is used to query the catalogue, and the other to download a file from
the archive.
The results from the query service are provided as JSON files with the properties of the observations found
in the specified time range (and instruments). These files include information about the date and time of
the observations, the instrument used, the field of view observed and the filename where that observation is
stored. We can download that files using the filename as an argument to the download service. The format
from the observation files vary depending on the instrument (specified in the following section).
Read the information on the archive website to understand how to query the service, what parameters are
accepted and what are the defaults.
We need to create a set of tools within the Python package to query and download the files. They need to
be available from aigeanpy.net.query_isa and aigeanpy.net.download_isa. They must accept
all the parameters listed on the website. Additionally, the download_isa need to allow the user to specify
where to download the file (save_dir).

1.2 Different instruments, different file types
Data from each instrument is provided in a different type of file.
Lir uses the Advanced Scientific Data Format (ASDF). The asdf Python library can read them and extract
the data and metadata from these files.
Manannan uses Hierarchical Data Format 5 (HDF5). As with the asdf, this type of file contains the data
and the metadata together. The h5py Python library can load them.
The Fand instrument stores the data in npy format and the metadata in JSON files. npy files can be read
from NumPy’s load and the Python Standard Library provides support to load JSON files. The archive
provides that pair of files in a single zip file (for which Python Standard Library also provides a module to
load: zipfile).
Finally, the Ecne instrument doesn’t take images, but infers some measurements of the 300 deepest areas in
the region. The measurements are turbulence, salinity and algal density for these points. They are stored
in CSV.
􀄎 Ideally a user shouldn’t need to unzip the file before loading it with the library. The io.BytesIO
class can help you to load the file in memory. Take a look at how it’s used on the exemplar at the
beginning of our course notes.
1.2.1 Getting the coordinates right
Arrays are stored in Python as (rows, columns). However, we normally refer to places in a map as (x, y)
coordinates (with x running from left to right, and y running from bottom to top). Also when displaying an
image in matplotlib with imshow, by default, you’d get the axis as its origin is in the top-left corner and
positive y-values going downwards. For this library, we will need to manage two type of coordinate systems:
pixels and earth.

Figure 1: Difference between the two coordinate systems. The plot in the left shows the default when
visualising an array, the (0, 0) is on the top left corner. On the right, the same array is shown as a map,
which a set of (x, y) coordinates are represented within a pixel. In this case each pixel corresponds to 10
meters and the origin is within the second row, and the first column.
To ease the conversion between the coordinate systems you’ll need to create two helper functions, which are
called earth_to_pixel and pixel_to_earth.

Each image will come with an array of a particular size (and shape) and the metadata will provide the
resolution (in meters per pixel), the earth x- and y-coordinates (in meters) as the (lower, upper)
boundaries for each axis. The field of view (i.e., the difference between the boundaries) divided by the
resolution should give you the shape of the array (in the (columns, rows) order).

DNA Manipulation

DNA Manipulation

Computer science concepts can be applied to solve problems in many different domains. In this assignment, the problem domain is DNA manipulation. We have provided a page on DNA manipulation that covers the information — and defines the terms — that you will need. Bookmark that page: it will be a useful reference for this assignment.

To help guide your reading, you should make sure that you learn what the following terms mean as you read the DNA manipulation page. We have written the rest of the handout under the assumption that you know their definitions.

  • base
  • base pair
  • DNA
  • palindrome
  • DNA palindrome
  • restriction site
  • restriction enzyme
  • recognition sequence
  • DNA mutation
  • 1-cutter

What To Do

In this assignment, you will create

Video Poker Game

Vegas

Goals

The goal of this assignment is simple: write a video poker game. The game will follow the jacks or better rules listed at Wikipedia.

Specifics

Playing Video Poker

Video poker works a lot like real poker, though there are a few differences. A game follows these steps:

  1. Before any cards are dealt, the player selects the number of credits she wants to wager on the hand (between 1 and 5). These credits are deducted from the player’s balance before the hand is dealt. If the player wagers more than she has, put up a status message and ask again.
  2. The hand is dealt and displayed.
  3. The player selects zero or more cards to keep. Cards are selected by clicking on them; the word HELDappears over cards that will be kep

Python Lab

(Matrices and File I/O) Write a Python script named cluster_counter.py that takes command line arguments. The first argument will be a filename. The file loaded will contain an n by m matrix of different characters. This n by m matrix denotes different clusters where each same character represents a group. Casing is not important (i.e A and a are the same group). Touching characters (meaning adjacent and diagonal) of the same group are assumed to be in the same cluster. Write a program that tells the user how many groups exist and for each group, how many sub clusters exist.  (20 points)
Example file test.m
A B A A A
A B A A A
B B A A A
python cluster_counter.py test.m
You have 2 groups: A, B
The Number of clusters are listed below
A : 2
B : 1

Assignment 3 COMP9021, Session 2, 2015

Assignment 3
COMP9021, Session 2, 2015
Aims: The purpose of the assignment is to:
 process command-line arguments in the style of Unix utilities;
 become familiar with trees;
 possibly implement recursive solutions;
 develop problem solving skills.
Command line arguments
Both programs will read command line arguments. To read those we import the sys module and
process sys.argv, a list of strings whose rst element is the name of the module being interpreted,
whose second element is the rst command line argument, whose third element is the second command
line argument, etc. So if no command line argument is provided, then sys.argv is a list of length 1.
Submission
Your programs will be stored in les named display_tree.py and roman_arabic.py. Upload yours
le using WebCMS. Assignments can be submitted more than once: the last version is marked. Your
assignment is due by November 1 11:59pm.
Assessment
For each test, the automarking script will let your program run for 30 seconds.
For each of the two program

Logic Plan

Introduction

In this project, your Pacman agent will logically plan his way to the goal. You will write software that generates the logical sentences describing moving, eating, and (predictable) ghosts. You will encode initial states and goals and use logical inference to find action sequences that are consistent with these.

This diagram outlines the different steps of the propositional logic planning process.

 

As in Projects 0 and 1, this project includes an autograder for you to grade your answers on your machine. This can be run with the command:

python autograder.py

See the autograder tutorial in Project 0 for more information about using the autograder.

The code for this project consists of several Python files, some of which you will need to read and understand in order to complete the assignment, and some of which you can ignore.

Files you’ll edit:
logicPlan.py Wh

Grocery Store Simulation

Assignment 1 – Grocery Store Simulation

Marking scheme posted!

Sample tests posted! (See the unit test file for details.)

Grocery stores often have a difficult task: they must determine how many employees to hire to staff checkout lines during varying levels of customers throughout the day. Too few open lines means customers spend time angrily waiting; too many, and the store loses money paying its employees. It’s also important to get the right mix of regular and express checkout lines, and perhaps even self-serve lines. Which combination is best depends on what kind of customers the store has.

In this assignment, you’ll build an event-driven simulation for a grocery store, which will model customers using different types of checkout

GMU cs112 solution

Programming Project 6

This semester you will be writing a program that models elements of recognizing and creating characters. Optical character recognition is an important area of research that allows photographs or printed documents to be digitized; by doing so, these documents are made available for machine-based searching. On the flip side, http://en.wikipedia.org/wiki/CAPTCHAis a system for differentiating between humans and computers: the goal here is to generate a non-machine readable image that a human could identify. CAPTCHA helps reduce the amount of spam on the Internet.

We will implement a highly limited type of image matching, processing, and creation this semester. Rather than write this project at once, we will break the project down into

game Battleship python implementation

4.1 Overview

Computer games are nearly as old as electronic computers themselves. The first tic-tac-toe game was programmed on an EDSAC vacuum-tube computer. Your job will be to expand the Battleship program started in earlier labs into a fully-playable game.

4.2 The game of Battleship

Wikipedia has a thorough description of the origins of the game of Battleship. For purposes of this assignment, follow the following rules.

1.The game is played between two players (one human and one computer for your program).

2.Each player has an identical set of ships. Each ship has a length, a name (e.g., “submarine”), and a symbol (a letter, e.g., “S”).

3.Each player has a grid, called the “battle board”,  which is mostly hidden from the other player. The grid is used for marking the locations of the pl