Looking ahead to their Fourth of July return to Earth, astronauts Thomas K. (Ken) Mattingly and Henry W. Hartsfield today began wrapping up the last tasks they have been assigned on the fourth and final test flight of the space shuttle Columbia.

Mattingly photographed tropical storm Carlotta off the coast of Baja California, put on his space suit to help flight planners figure out the least cumbersome way for shuttle astronauts to take walks in space and beamed back breathtaking color television of stars rising and setting in the bright blue atmosphere that had just begun to turn red before sunrise on the dark side of the Earth.

"That's the Earth by moonlight on the left-hand side and those big white blobs called stars are penetrating the atmosphere and they eventually become occulted as they go down through the Earth's disc," Mattingly said, describing the scene. "It sure is strange to see stars that seem to set and rise across the Earth's surface."

When they land at 12:10 p.m. EDT Sunday at Edwards Air Force Base in California's Mojave Desert, Mattingly and Hartsfield will be landing before President Reagan, a nationwide television audience and a predicted record throng of 500,000 people.

The astronauts will begin their descent to Earth at 11:10 a.m. when they slow down their space liner over the South Pacific near Guam. As they have done all through this last test flight, Mattingly and Hartsfield will push the 100-ton craft to its limit.

On their way down toward Earth at 14 times the speed of sound, the astronauts will begin a maneuver they call a "pushup, pullover," which involves moving the nose rapidly up and down 10 degrees at the rate of one degree per second.

Mattingly and Hartsfield will also come down in a steep dive to heat up the fuselage of the shuttle to test its protective tile system to the utmost.

"This is a test flight, a flight that has been the least conservative of the four tests we've flown so far," Flight Director Charles (Chuck) Lewis said at the Johnson Space Center, where Columbia's flight is directed.

"This is what test flights are all about. What we're doing here in the pushover, pullups is we're putting in a small error to the computer that's doing the flying and we're measuring the response of the vehicle as it corrects that error. We're looking at the stability of the aircraft."

Flight directors would like Mattingly and Hartsfield to make Sunday's landing into a crosswind in the desert. But chances are there will be little crosswind when they land that early in the morning. If there are little or no crosswinds on the dried-out lake beds that serve as a landing field, the astronauts will land the Columbia on the concrete runway at Edwards to give flight planners a feel for future such landings. In the future, the space shuttle will make routine landings at the Kennedy Space Center in Florida, where it now only takes off.

"Psychologically, landing on concrete instead of an endless lake bed is different," Flight Director Harold Draughon said today. "The concrete runway is only 300 feet wide and 15,000 feet long. It doesn't go on forever the way the lake bed runways do."

The astronauts went to bed before 7 tonight and will go to sleep Saturday before 6 p.m. Mattingly and Hartsfield have been turning in earlier each day to get their minds and bodies used to a schedule that will awaken them before midnight Saturday night so they can be wide-awake for an early morning landing on the Fourth of July.

Awakened today by the theme music from "Chariots of Fire," the astronauts were on the job at 3 a.m. An hour after they woke, the burned-out empty upper stage of a seven-year-old Soviet space shot whizzed by them above and in front at a speed of 6,200 mph. It was the closest any manned American spacecraft had come to any of the countless hulks that litter the black seas of space.

Though there was never any danger of collision, the astronauts had been told they would come close over Australia today to the Soviet rocket. So fast did the hulk speed by them that neither astronaut saw it.

"No way they could see that thing," Draughon said. "You would have had to be looking at exactly the right place at exactly the right time and not blink."