讲解SCIE1000编程、Python编程调试、辅导Python程序设计 调试Matlab程序|解析R语言编程

- 首页 >> CS
SCIE1000 Semester One, 2021
Python and Communication Assignment
1 The scenario
A public science museum in St Lucia is planning to update its exhibit. A feature of the museum
is that each exhibit item is accompanied by two explanations, each written for a different audience.
One explanation is pitched to the “science rookie” and the other to the “science enthusiast”. Patrons
read the explanation tailored to the level at which they feel most comfortable. Some characteristics
of a typical audience member in each category are described in Table 1.
Patron Type Typical characteristics
Science Rookie Not familiar with scientific terminology or notation;
will need terminology explained using a simple vocabulary;
is unfamiliar with graphs;
may be a younger person, possibly 10+ years of age;
likes to press buttons.
Science Enthusiast Familiar with common scientific terminology and notation (not overly technical);
will need terminology explained using somewhat sophisticated vocabulary;
is prepared to read longer passages of moderate complexity;
is familiar with graphs;
likes to press buttons.
Table 1: Characteristics of different patrons
The museum is planning an exhibition called “Mother Nature, the Mother of Invention.” The
topic is biomimicry, and the aim is summarised in the following passage from the exhibition prospectus:
With this exhibition we aim to instil in our patrons a sense of wonder at the abilities
displayed by animals to withstand harsh environments. Patrons will learn about mechanisms
by which certain animals can improve the survivability of a group as a whole, and
consider possible developing technologies that mimic these natural behaviours.
Recently, biomimicry research has looked at applying the modelling of emperor penguin huddles
to multi-robot systems, with the aim of improving the survivability of the robot group in harsh
environments [5].
The museum director has asked the SCIE1000 teaching team for help in finding skilled volunteers
to develop exhibit items. Once developed, the items will be maintained and potentially modified
by museum staff, each of whom has a strong background in high-school mathematics, together with
at least a beginners level of Python experience. We assured the director that SCIE1000 students
are skilled at: making mathematical models using a mathematical toolkit familiar to any student
of Mathematical Methods (aka Maths B, or equivalent); writing Python programs, including those
which use arrays, loops, plots and new functions; and communicating scientific information to various
audiences.
1
2 An overview of the task
You will write an interactive Python program that will run on a machine in the exhibition hall
at the new science museum, as part of this exhibition. Your program will guide users to a better
understanding and appreciation of how and why emperor penguins form huddles. The information
you need to create the relevant models is provided in Section 5 of this document, and a high-level
overview of how to complete the task is provided in Section 6.
This assignment requires you to produce and deliver two items:
(D1) A Python code file that satisfies the specifications in Section 7. This includes following the
logical flow laid out in the flow chart provided in Figure 4 (see Page 10).
(D2) An audio-video screencapture file (3-4 minutes long) in which you show your code and communicate
the overview of your approach to museum staff who will need to maintain your code.
3 Submission and grading
Both deliverables (D1) and (D2) are to be uploaded via Blackboard submission link by 2pm on
27 May, 2021. Late submissions without an approved extension will be penalised according to the
policy in the ECP; consult Section 5.3 of the Electronic Course Profile for more information.
Your submitted code will be run and tested as part of this grading process. A rubric (grading
criteria) for this assignment is on Page 11. The file that you submit will be checked using software
which is specially designed to detect plagiarism in code. Consult Section 6.1 of the ECP for more
information and procedures concerning plagiarism.
This assignment has an advanced section which must be attempted by students aiming for
grades of 6 or 7 (see the grading criteria for more explanation). The shaded section of the flow chart
indicates this advanced section, and more information is provided in Section 5.5. If you have any
questions, please contact the course lecturers via Campuswire (see Section 4 below).
4 About getting help
This assignment is a piece of summative assessment, designed to let you demonstrate your level of
mastery of several learning objectives in this course. As such, it is very important that the work you
submit is all your own. This does not mean that you cannot receive help in regards to this assignment,
but that help must be limited to general advice about modelling, Python and communication. This
task sheet has been carefully constructed, and part of your job is to interpret the information it
contains. Some choices have been left to your judgement, and this is intentional.
Remember that you must not look at anyone else’s code and you must not show your code to
anyone. Both of these actions are examples of behaviour that may be considered academic misconduct.
No code from your assignment attempt should be posted on the course Campuswire site, or
any other site, at any time. However, if you have problems with your code, you may develop some
generic sample code that demonstrates the issue that you are having (but does not relate to the
assignment). This can be discussed with others and/or posted to Campuswire for assistance. All
such Campuswire posts should be made visible to all students, so that everyone can see the question
and the answer from lecturers.
2
5 Modelling Emperor Penguin Huddles
5.1 Emperor penguins and breeding
Penguins are flightless birds, with flippers instead of wings, adapted to living in a marine environment.
Emperor penguins (Aptenodytes forsteri) live on the Antarctic continent and are the largest known
species of penguin, with adults weighing around 40 kg [2]. The emperor penguin is the only bird
that breeds during the Antarctic winter. They breed on sea ice which is well away from the ocean
where these penguins feed. Emperor penguins mate in late April and May. Once a female penguin
lays an egg, she returns to the sea, usually around late May / early June [2]. Male emperor penguins
protect and incubate the egg by placing it carefully between their feet and a fold of their skin; it
takes between 65 − 75 days for the egg to hatch [2]. This means that by the time the male penguins
finally return to the ocean for food, they have been fasting for about four months [3]. Once a chick
hatches, emperor penguins share parental duties [2].
The museum exhibition is interested in explaining the conditions experienced by a male emperor
penguin, protecting an egg, in a harsh Antarctic winter (approximately June-August).
5.2 Modelling winter temperatures in the Antarctic continent
In 2008, the authors of [9] studied “a medium-sized emperor penguin colony (∼ 2000 animals)” close
to Neumayer Antarctic Research Station (70◦S 8◦W). To model the temperatures faced by emperor
penguins, we will use meteorological data from Neumayer Antarctic Research Station. The table
below is adapted from [4], and is restricted to some of the coldest months of the year.
Month May June July August Sept
Mean temp (◦C) −21 −22 −24 −23 −23
Max temp (◦C) −2 −5 −4 −4 −3
Min temp (◦C) −45 −45 −46 −44 −46
Table 2: Mean, maximum and minimum air temperature values, Neumayer station from 1993-2004
To model the average (mean) daily temperatures in the winter months, we will use a simple model
for the average temperature Tavg (in ◦C) over time (in days since 1 June). Our model assumptions
are:
• On 1 June Tavg = −21◦C;
• Tavg declines linearly from 1 June until 16 July, at which point Tavg = −24◦C;
• Tavg increases linearly from 16 July until 31 August, at which point Tavg = −23◦C.
Temperature varies throughout the day as well. In Table 2, we are given the minimum and
maximum temperatures seen in a given month, over about a decade of measurements. A typical
day usually does not vary as drastically as those highest and lowest recorded temperatures; most
measurements were within 8 − 10◦C of the average daily recordings [4]. To model the temperature
at a given time of the day, you may use a sine function, with parameters that you must choose based
on the information provided here.
3
5.3 Wind Chill
When very cold temperatures are combined with winds, the apparent temperature (or wind-chill
temperature) will feel colder than the air temperature. A model for the apparent temperature AT
in ◦C, which is used by the National Weather Service in the USA and by Environment Canada (see
for example, [8]) is:
AT = 13.112 + 0.6215T − 11.37v
0.16 + 0.3965T v0.16
,
where T is the air temperature in ◦C and v is the wind speed in km/h (assumed to be at least 5
km/h). Environment Canada recommends the model is only used for air temperatures strictly less
than 0◦C [8].
Average wind speeds experienced by emperor penguin colonies are around 15 km/h [3] with
typical maximum wind speeds of about 30 km/h [9]. However, emperor penguins have been known
to endure wind speeds of up to 180 km/h [9].
5.4 Huddling
Emperor penguins form large huddles in order to protect the group from the cold [1, 3, 9, 7]. Huddling
decreases the required energy expenditure of individual penguins [1]. Temperatures inside a huddle
have been found to reach temperatures as high as about 37◦C [3].
Huddles can be “loose” or “tight” [3, 6], where a tight huddle has a high density, nearly hexagonal
packing arrangement [9]. The images in Figure 1 are taken from [6] and show examples of emperor
penguin huddles. Huddles are not motionless; even in tight huddles, where individual movement
is not possible, the penguins slowly shuffle as a group. The shape of a tight huddle, when viewed
from above, may be circular or more elongated. As wind speed increases, penguins on the outside
of the huddle receiving the most wind and exposure to the cold will shift along the huddle so that
they move to the back of the huddle, where they are then protected from the wind, creating a more
elongated shape.
Figure 1: Examples of loose (left) and tight (right) emperor penguin huddles.
In a 2008 study of emperor penguins, Gilbert et al.[3] found that wind speed had a positive
impact on the number of loose huddles formed per day and temperature had a significant effect on
the number of tight huddles formed per day.
4
5.5 Details on effects of wind on huddle shape (Advanced Section only)
An enthusiast user is likely to be interested in the modelling done by Waters et al. [7] on the effect of
wind on penguin huddle shapes. The key assumption of their model is that each individual penguin
seeks to reduce its own heat loss. Thus, in their model, a penguin on the boundary of the huddle
exposed to the wind will move downwind, to the leeward side of the huddle in order to be protected
from the wind. In [7], the authors say, “Our model recovers important features of actual huddles such
as their overall shape, downwind motion, and an equal distribution of access to the benefits of the
huddle among penguins.”
Figure 2: Time progression of penguin huddle simulation with 100 penguins [7].
Waters et al. [7] claim
For small [wind speeds], when diffusive effects act to render the temperature distribution
nearly uniform, the aspect ratio is close to one, depicting a more circular huddle. In
contrast, for large [wind speeds], where only a small leeward region is sheltered from the
wind, the aspect ratio is much larger than one, depicting a more elongated huddle....The
wind pushes the heat distribution more narrowly around the huddle, causing the locations
on the upper and lower edges of the huddle to exhibit more heat loss and thus be less attractive
to relocating penguins. As a result, the huddle formation loses a layer of thickness
and becomes more elongated.
The shape of a tight huddle, when viewed from above, may be circular or more elongated and
can be roughly modelled by an ellipse (see Figure 3).
5
Major axis
Minor axis
Figure 3: General shape of an ellipse. The shortest and longest axes are called the minor and major
axis, respectively.
Waters et al. [7] describe the P´eclet number, Pe, as a non-dimensional number that is proportional
to the wind speed and therefore captures the effects of varying the strength of the wind. They used
model simulations to study how huddle thickness w relates to Pe, where the huddle thickness is given
by the number of penguins across the minor axis.
The following data is adapted from simulations in [7] with 400 penguins. You may assume that
the number of penguins across the major axis of the ellipse shape is approximately 400/w.
P´eclet number (Pe) 1 2 10 30 100 300 1000 1100 1200
huddle thickness (w) 20 18 13 9 8 4 4 3 3
Table 3: Huddle thickness against P´eclet number for penguin huddle simulations
6 A detailed overview of the task
Your assignment submission must follow the specifications listed in Section 7. Below, we first give a
high-level overview of how to approach the main section and the advanced section.
To complete the main section, you will need to:
• Find an appropriate mathematical function to model the average winter temperature, for a
given day, using the information provided in Section 5.2. You will write a function average_winter_temp
in your code which implements this model (see Section 7 for specifications).
• Find an appropriate mathematical function to model the winter temperature, which takes account
of daily fluctuations, using the information provided in Section 5.2. You will write a
function winter_temp in your code which implements this model (see Section 7 for specifications).
• You will write a function wind_chill in your code which implements the wind chill model in
Section 5.3 (see Section 7 for specifications).
• According to the main section of the flow chart:
– Print information and ask for user input related to the contexts of Antarctic temperatures,
wind chill and penguin huddles, in a manner accessible for the patron type.
6
– Provide a graph for the enthusiast user for temperatures over the month chosen by the
user.
• Include a description of how you approached this section of your code in your screencapture
video (D2), including (briefly) how you developed your models and the overall code structure.
To complete the advanced section, you will need to:
• Find an appropriate mathematical function to model the simulation data in Table 3. It will be
helpful to consider the log-linear plot and log-log plot of the data, and use one of these in the
development of a model.
• According to the “Advanced section” of the flowchart:
– Provide a graph of the data from Table 3 which also shows the model you have fit to it.
– Provide a brief explanation of your model to the enthusiast user.
– Ask the user to input a P´eclet number and display the rough huddle shape that is predicted.
• Include a description of how you approached this section of your code in your screencapture
video (D2), including how you developed your model for huddle thickness as a function of the
P´eclet number.
7 Specifications for your submitted file
Specifications about the Python:
• Museum staff have supplied a flowchart describing how the program should run (Figure 4 on
Page 10). Your code must be an implementation of the flowchart provided.
• Your code must be well-structured and follow the guidelines for programming practice, as
introduced in SCIE1000.
• Whenever you prompt the user for information, you may assume they enter an appropriate
number, and you can store their answer as a float. You do not need to check for incorrect
inputs.
• You may only use Python commands introduced in SCIE1000. Recall that museum staff
must be able to maintain and modify the code, so you may only use commands that they
understand. Museum staff have a beginner’s level of experience using Python, which you may
regard as the equivalent of a student who has taken SCIE1000. The Python commands you
have covered in this course should be more than sufficient to complete the assignment.
• Museum staff have identified several functions that they think will be useful in possible modi-
fications and extensions of the code. You must define these functions in your code, with
the exact names specified below and which take the same arguments in the order specified. You
should use these functions in your code as appropriate. You may define other new functions as
needed.
7
(a) You must define a function called average_winter_temp which takes one input, days since
1 June (in an appropriate interval), and returns the average daily temperature (in degrees
Celsius) at that day, according to the average winter temperature model from Section 5.2.
(b) You must define a function called winter_temp which takes one input, time since midnight
on 1 June (in an appropriate interval), and returns the temperature at that time, according
to the winter temperature model with daily fluctuations from Section 5.2. You may choose
whether to measure the input in hours or in days (where partial days are accepted input).
(c) You must define a function called wind_chill, which takes two inputs, air temperature
(in degrees Celsius), and wind speed (in km/h), in that order, and returns the apparent
temperature according to the wind chill model in Section 5.3.
• Note that a function called graph_ellipse is already defined in the program template file
(available on Blackboard). The function takes two arguments, a and b, and graphs a figure of
an ellipse with minor axis of length a and major axis of length b. This function is only needed
for completing the advanced section (see the flowchart on Page 10).
Specifications about the communication:
• All messages to the user, including prompts to enter data, should communicate in a manner
appropriate for the level of patron and should serve the purpose of the program.
• You should write no more than a couple of sentences for each piece of information you explain
to the user. Follow the principles for communication in science as described in Appendix B of
the lecture book. Be precise, clear and concise!
• You should use units appropriately in your communication with the user. Make sure you are
aware of the units of values being passed into functions and the units of values being returned
from functions.
• You should include useful and appropriate comments in your code to help the museum
staff who may need to maintain and modify the code. Any variable names and function names
you define should be chosen with communication in mind.
• Whenever you produce a graph you should provide appropriate labels and explanatory
text.
• Your screencapture video should provide a clear overview of how your code works
and why you made the choices you did. This does not replace excellent commenting in
the code. One way to create such a file by opening a Zoom meeting, sharing your screen, and
selecting Record → Record to this computer.
• If you choose to use sources other than those cited in this task sheet, you should include a
bibliography as comments at the end of your code, to show the museum staff maintaining the
code where you obtained any relevant information you used. Any referencing style is fine.
8
File type and file name:
• Your assignment (D1) should be saved as a .py file called InteractivePenguins********.py
with the string ******** replaced by your student number.
• Your screencapture audio/video file (D2) should be saved as Explanation********.mp4
with the string ******** replaced by your student number.
References
[1] Ancel A, Visser H, Handrich Y, Masman D, Le Maho Y (1997) Energy saving in huddling penguins. Nature 385:
304–305.
[2] Australian Antarctic Program. Penguins. https://www.antarctica.gov.au/about-antarctica/
animals/penguins/emperor-penguins/, accessed 13 December 2020.
[3] Gilbert C, Robertson G, Le Maho Y, and Ancel A. (2008) How do weather conditions affect the huddling behaviour
of emperor penguins? Polar Biology 31: 163–169.
[4] K¨onig-Langlo G C. and Loose B. (2007) The meteorological observatory at Neumayer stations (GvN and NM-II),
Antarctica, Polarforschung, 76, 25–38, 2007.
[5] Mina T and Min B-C. (2018) Penguin huddling inspired distributed boundary movement for group survival
in multi-robot systems using Gaussian processes. Proceedings of the 2018 IEEE, International Conference on
Robotics and Biomimetics December 12-15, 2018, Kuala Lumpur, Malaysia.
[6] Richter S., et al.(2018) Phase transitions in huddling emperor penguins. J Phys Appl Phys, 51: p. 214002
[7] Waters A, Blanchette, F, Kim AD (2012) Modeling huddling penguins. PLoS ONE 7(11): e50277.
doi:10.1371/journal.pone.0050277
[8] Wind Chill and Humidex Calculators, Government of Canada, https://weather.gc.ca/windchill/wind_chill_e.html,
accessed 12 March 2021.
[9] Zitterbart D P, Wienecke B, Butler J P, and Fabry B. (2011) Coordinated movements prevent jamming in an
emperor penguin huddle. PLoS ONE 6(6): e20260. doi:10.1371/journal.pone.0020260
9
Print a welcome message that is appropriate for all patrons. Prompt the user to enter their Patron type
Print an introduction about Emperor penguins and this interactive program
Yes
Print a farewell message
No
User is an
“enthusiast”?
Yes
Advanced section
No
If user is an
“enthusiast”?
Yes
Print a general message about winter temperatures.
Calculate the temperature using the function winter_temp and print a useful message.
Prompt the user to select a day of the month.
Display a graph of the winter temperature over the chosen month,
including daily fluctuations.
Print a useful message about wind chill. Prompt the user to enter a wind speed.
Calculate the apparent temperature using wind_chill. Print a useful message.
Print a brief description of emperor penguin huddles. Qualitatively explain
the basic effect of wind speed on the shape of a tight huddle.
Ask the user if they want to choose another winter month.
Prompt the user to select a winter month.
Display a graph of the data on huddle thickness vs Péclet
number, with an appropriate model fit to it. Provide a brief
explanation of this model.
No
Prompt the user to pick or enter a time of day (in at most hourly increments).
Print a useful message about the general predicted temperature that day.
Show the approximate predicted huddle shape, using graph_ellipse.
Prompt the user to enter a Péclet number.
Ask the user if they want to choose another Péclet number.
Yes
No
Figure 4: Flowchart for the interactive program (shaded section indicates the advanced section).
10
Python and Communication Assignment Grading Criteria
Your grades for the Python and Communication sections of the assignment (each on a 1–7 scale) are
calculated by using the grade that best matches your answers for the main sections plus the extra
grades for the advanced sections. Your overall grade will thus be up to a maximum of 14. The table
below shows the criteria for each grade.
Grade Python (1–7) Communication (1–7)
1 The code is limited and displays little understanding
of the modelling involved.
Communication is very poor and would be
difficult to understand by any audience.
2 The code fails to run for any input, does
not meet the specifications, and/or has serious
conceptual errors in the modelling.
The communication of the relevant scientific
information (in the code and to patrons)
is generally poor.
3 The code runs for some expected inputs,
meets at least some of the specifications,
and/or may have some significant conceptual
errors in the modelling.
The communication of the relevant scientific
information (in the code and to patrons)
lacks clarity or is not at the appropriate
level for most target audiences.
4 The code runs without error for most inputs,
mostly meets the specifications, and
mostly represents the mathematical modelling
with perhaps only some conceptual
and/or mathematical errors.
The communication of the relevant scientific
information (in the code, the screencapture
video, and to patrons) is adequate
for most target audiences. There may
be some limitations in the communication
within the code and/or to patrons.
5 The code runs without error for all expected
inputs, largely meets all the specifications,
and accurately represents the
modelling with perhaps only one or two
minor errors.
The communication of the relevant scientific
information (within the code, the
screencapture video, and to patrons) is
mostly clear, fluent, and uses a level and
style appropriate for each target audience.
Advanced Section
0 Not completed, or the advanced code has
significant conceptual errors.
Not completed, or the communication in
the advanced section is poor.
+1 The code for the advanced section runs
with only minor errors and mostly represents
the modelling with some conceptual
or calculation errors.
The level of communication is adequate
throughout the advanced section but
would require some editing before use in
an exhibit. The advanced section is also
communicated in the screencapture video.
+2 The code for the advanced section runs
without error and accurately represents
the modelling with at most one minor error.
The level of communication is clear
throughout the advanced section and
would be suitable for use in an exhibit
with perhaps only one or two small
changes. The advanced section is also
clearly communicated in the screencapture
video.
11

站长地图